Sequencer not working

Dec 9, 2010 at 12:57 PM

I see from the front page of this project, "sequencer not well tested". I tried it, and either I'm doing something wrong, but all I get is silence:

Synthesizer synth = new Synthesizer(...);

Sequencer seq = new Sequencer();

synth.AddSequencer(seq);

now = seq.GetCurrentTicks();

seq.PlayNoteAt(Event.NoteOn(0, 60, 127), now + 500, false);
seq.PlayNoteAt(Event.NoteOff(0, 60), now + 1000, false);

Threads.Sleep(5000);

(The above doesn't show sound font loading...)

Oct 3, 2011 at 12:38 PM
Edited Oct 3, 2011 at 12:39 PM

I know this was posted almost a year ago, but for anyone Google searching this later:

To fix this issue, open up FluidSynthWrapper.cpp from the FluidSynthWrapper solution. 

Under the Sequencer class, there are two functions that need to be fixed: PlayEvent and and PlayEventAt.

The problem is that the event you create in C# is missing the reference to the synthesizer ID. To fix, add the following to each function before the call to fluid_sequencer_send--

::fluid_event_set_source(ev->GetEventObject(), -1);

::fluid_event_set_dest(ev->GetEventObject(), seqSynthId);

So the two functions should be--

void Sequencer::PlayEvent(FluidSynthWrapper::Event ^ev){ 

::fluid_event_set_source(ev->GetEventObject(), -1); ::fluid_event_set_dest(ev->GetEventObject(), seqSynthId);

::fluid_sequencer_send_now(this->seq,ev->GetEventObject());

}

void Sequencer::PlayEventAt(Event^ ev, unsigned int time, bool absolute){

::fluid_event_set_source(ev->GetEventObject(), -1); ::fluid_event_set_dest(ev->GetEventObject(), seqSynthId);

::fluid_sequencer_send_at(this->seq,ev->GetEventObject(),(unsigned int)time,(int)absolute);

}