[gecode-users] Advices for creating new variable type?

Torsten Anders Torsten.Anders at beds.ac.uk
Tue Apr 26 12:55:35 CEST 2016


Dear Geoffroy,

> For example, in OM there is a Note object with some attributes such as the pitch, the velocity, the duration and I want to create a NoteVar in Gecode to use all possibilities of constraint programming on Note object.

Why not represent your note object with several variables, e.g., of integer domain for the pitch and duration. That way you get all the constraint propagators defined for that domain for free (otherwise you would have to code that all yourself for your new domain, I understand). Besides, you will also need propagation between the different parameters of a note object, i.e., it should not be a single variable. 

Some comments on the individual note parameters. By representing pitches and durations as integers you are limiting what the result can express, but this may still be a good compromise. For example, for pitches you could allow for arbitrary equal temperaments with an integer representation, which is relatively generic. For music in just intonation you would ideally have a domain of ratios (which you do not have in Gecode, AFAIK), and for unequal temperaments a domain of reals/floats (which you could have), but an approximation with integers with a high number of pitches per octave (e.g., 1200 for cent resolution) should be fine. 

For duration and other rhythmic parameters the situation is a bit more tricky. By limiting yourself to integers you are always limited with respect to contemporary music practice, where you have nested tuplets etc. If you are willing to limit your results to music with a fixed set of possible tuplets and without nesting, then an integer-based representation is fine. 

I suggest you make a velocity parameter only optional to avoid creating lots of variables later that are virtually never used. From the many music CSPs that I know of, velocities are very rarely required. If you want to implement those, then it might make actually sense to implement the full or at least large parts of the MIDI protocol for constraint programming (or consider OSC instead), i.e., not just note velocities, but also the MIDI channel of notes, other events like CC messages etc. That may lead to new applications.   

> What would be the best idea of implementation for NoteVar to easily apply the constraints and the search on this object? 

I am happy to discuss the advantages and disadvantages of different constraint-based music representations off-list. You may also want to have a look at the following literature survey, that compares the design of multiple music constraint systems in quite some detail. 

  Anders, T. & Miranda, E. R. (2011) Constraint Programming Systems for Modeling Music Theories and Composition. ACM Computing Surveys. 43 (4), 30:1–30:38.

Best wishes,
Torsten

--
Dr Torsten Anders
Course Leader, Music Technology
University of Bedfordshire
Park Square, Room A315
http://www.torsten-anders.de



On 26 Apr 2016, at 09:27, Geoffroy Zoetardt <geoffzoet at hotmail.com> wrote:
> Hi everyone,
> 
> I’m actually developing a binding between Gecode and OpenMusic (composition software made by the IRCAM).
> During this project, I want to create new type of variable closer to the musical objects already existing in OpenMusic (OM).
> For example, in OM there is a Note object with some attributes such as the pitch, the velocity, the duration and I want to create a NoteVar in Gecode to use all possibilities of constraint programming on Note object.
> For now, my idea is to implement each attribute as an IntVar content in the NoteVar object because there are mainly two application that I need to do with NoteVar:
> - Be able to apply constraints and search on attribute individually (reason for implementing  them as IntVar).
> - Be able to apply constraints and search on the NoteVar object.
> Then I would like to have your advices on «  What would be the best idea of implementation for NoteVar to easily apply the constraints and the search on this object? ».
> I hope that it is clear enough.
> Already thank you!
> 
> Geoffroy Zoetardt
> _______________________________________________
> Gecode users mailing list
> users at gecode.org
> https://www.gecode.org/mailman/listinfo/gecode-users




More information about the users mailing list