[chuck-users] trying to implement a midi sequencer in chuck

Dana Batali dana.batali at gmail.com
Sat Feb 12 15:23:55 EST 2022


How about moving the MidiMsg object into the track function?
Of course it could always be a bug in MidiOut (I haven't used it.)

On Sat, Feb 12, 2022 at 12:18 PM d <dchuck at yurfish.com> wrote:
>
> Im using jack with fluidsynth.
>
> I had some confusion about whether each
> spork had its own "now" but I did a
> test script and that seems to be the case.
>
> I have tried adding me.yeild in various
> places but no joy.
>
> I created a midi file with a triad in
> in three tracks ..8 quarter notes.
> The events seem to be correct
> but the output is only the last
> spork. Perhaps its a problem
> with my setup.
> If i play the file with fludidynth
> I get what I expected.
>
> Any suggestions appreciated.
> thanks
> -----
> MidiFileIn min;
> MidiOut mout;
> MidiMsg msg;
> string filename;
> me.arg(0) => filename;
> if( !min.open(filename) ){
>    <<< "unable to open MIDI file:'",filename >>>;
>     me.exit();
> }
> mout.open(0);
> spork ~ track(1);
> spork ~ track(2);
> spork ~ track(3);
> 5::second=>now;
>
> function void  track(int t) {
>     10::ms =>now;
>     while( min.read(msg,t))
>     {
>   <<<t,msg.when,msg.data1&0x0f,msg.data2,msg.data3 >>>;
>       10::ms =>now;
>          msg.when=> now;
>          mout.send(msg);
>          me.yield();
>     }
> }
>
> 1 0.000000 0 75 0
> 2 0.000000 1 75 0
> 3 0.000000 2 75 0
> 1 0.000000 0 75 0
> 2 0.000000 1 75 0
> 3 0.000000 2 75 0
> 1 0.000000 0 60 90
> 2 0.000000 1 64 90
> 3 0.000000 2 55 90
> 1 18000.000000 0 60 0
> 2 18000.000000 1 64 0
> 3 18000.000000 2 55 0
> 1 0.000000 0 60 90
> 2 0.000000 1 64 90
> 3 0.000000 2 55 90
> 1 18000.000000 0 60 0
> 2 18000.000000 1 64 0
> 3 18000.000000 2 55 0
> 1 0.000000 0 60 90
> 2 0.000000 1 64 90
> 3 0.000000 2 55 90
> 1 18000.000000 0 60 0
> 2 18000.000000 1 64 0
>
>
> On Sat, 12 Feb 2022 10:22:17 -0800
> Forrest Curo <treegestalt at gmail.com> wrote:
>
> > So how is this going to change their timing? It shouldn't, unless some
> > process somewhere keeps running and won't yield when the wait ends
> > (and the waiting spork wants to start from there.)
> >
> > Jack or fluidsynth -- or what?
> >
> > On Sat, Feb 12, 2022 at 9:55 AM Curtis Ullerich
> > <curtullerich at gmail.com> wrote:
> >
> > > "advancing time" means "yield for this long." so the other shreds
> > > will be executing, or yielding, as their own timing dictates.
> > >
> > > On Sat, Feb 12, 2022, 06:40 Forrest Curo <treegestalt at gmail.com>
> > > wrote:
> > >> "Advancing time on a spork" means to "Wait until this amount of
> > >> time has elapsed."
> > >> If one spork is waiting for time to elapse, the others will be
> > >> doing... what?
> > >>
> > >> On Fri, Feb 11, 2022 at 1:36 PM d <dchuck at yurfish.com> wrote:
> > >>
> > >>>
> > >>> Yes,thats the one I modeled mine after.
> > >>> I removed the ugen stuff and replaced it with
> > >>> send (midiout).
> > >>> I have fluidsynth on jack The behaviour is strange.
> > >>> It appears that advancing time on a spork advances
> > >>> time in others and events get missed
> > >>> But I could be wrong. I have notes with
> > >>> no note off and CC that never happens
> > >>>
> > >>> It works fine for single track files.
> > >>>
> > >>> On Fri, 11 Feb 2022 13:10:20 -0800
> > >>> Dana Batali <dana.batali at gmail.com> wrote:
> > >>>
> > >>> > Hi Davud,  have you seen this example?
> > >>> >
> > >>> > https://cannerycoders.com/docs/chuck/examples/midi/midifile-play.html
> > >>> >
> > >>> > One obvious point is that min.read accepts a track number.
> > >>> > _______________________________________________
> > >>> > chuck-users mailing list
> > >>> > chuck-users at lists.cs.princeton.edu
> > >>> > https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
> > >>>
> > >>>
> > >>> On Fri, 11 Feb 2022 13:10:20 -0800
> > >>> Dana Batali <dana.batali at gmail.com> wrote:
> > >>>
> > >>> > Hi Davud,  have you seen this example?
> > >>> >
> > >>> > https://cannerycoders.com/docs/chuck/examples/midi/midifile-play.html
> > >>> >
> > >>> > One obvious point is that min.read accepts a track number.
> > >>> > _______________________________________________
> > >>> > chuck-users mailing list
> > >>> > chuck-users at lists.cs.princeton.edu
> > >>> > https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
> > >>>
> > >>> _______________________________________________
> > >>> chuck-users mailing list
> > >>> chuck-users at lists.cs.princeton.edu
> > >>> https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
> > >>>
> > >> _______________________________________________
> > >> chuck-users mailing list
> > >> chuck-users at lists.cs.princeton.edu
> > >> https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
> > >>
> > > _______________________________________________
> > > chuck-users mailing list
> > > chuck-users at lists.cs.princeton.edu
> > > https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
> > >
>
> _______________________________________________
> chuck-users mailing list
> chuck-users at lists.cs.princeton.edu
> https://lists.cs.princeton.edu/mailman/listinfo/chuck-users


More information about the chuck-users mailing list