Hallo, Atte Andr? Jensen hat gesagt: // Atte Andr? Jensen wrote:
I normally run things from a sequencer (muse) and this also holds for my current project. But I have a problem I'd like to solve with pd. I'd like to have an arpeggiator running in sync with muse, representing a few chords that's changing through the song.
My first thought was to have pd listen on two channels: all pressed notes on one channel represent the current chord. Midi notes on the other channel are only used as gate information. There should be a mode switch with up, down, up/down, random (did I forget some?).
Ok, I could go on and do my second external (since I would be able to write this up in C in no time), but I'm wondering:
Is there a similar wheel out there?
Would it be not-so-tricky to do as an abstraction? Newbie-me wouldn't
know how to a) hold onto a grab-bag of notes played on one channel and b) select them according to the selected mode. Which data structure would be nice to store/retrieve from in such a case (should dynamically grow/shrink)?
Of course if you prefer to use C and just want to use Pd as a kind of library to make things like accessing soundcards or midi ports easier, just go on with it, this is a perfectly fine use of Pd.
Personally I wouldn't bother with an external for this, however, as it's very easy to do these things in Pd itself, and it may also be faster to adapt, because you don't need to write/compile/reload anything, just change the patch and be done with it.
To your specific problem: You should make yourself familiar with the table-object, with tabread and tabwrite, learn how to write counters in Pd (I posted a tutorial for this here several times), take a look at the random object, spigot also would be handy here, as could be the object "bag".
Also take a look at some of my list-abs abstractions to get some ideas of things that are possible with the list-object.
Then an approach you could try would be to make a 128-element table, write a 1 at every position, that has an active note, a 0 wherever there was a note off. Then everytime, a new note(off) comes in, update the table and dump the active notes into a second table, that you read out with tabread in whatever way you like: Either use a counter idiom to generate lookup indices or the random object etc.
Another possibility for selecting notes to play with the appregiator is implemented in the "sel-princ.pd" abstraction of the RTC-library. It has four lookup methods already built in, that are inspired by serialism: Rota, Series, Alea and Sequence.
Frank Barknecht