Skip to contentSkip to conversation

General Guidelines? (MIDI)

DISCUSSION Pedro Lopez-Cabanillas 3 participants 3 messages Jan 16, 2003 – Jan 19, 2003 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw
Quoted 7 lines · Brian Victor

I've removed all attachments to wxWindows, so anyone should be able to compile my test program. So I don't have to keep sending snippits out of context, the code is here:

http://www.personal.psu.edu/users/b/h/bhv1/nowx.cc or
http://www.personal.psu.edu/users/b/h/bhv1/nowx.cc.html (syntax colored) (g++ nowx.cc -o nowx -lasound)

In short: start the queue before sending events, add snd_seq_drain_output at end of SetTempo method.

I wrote some example programs in plain C while learning ALSA API (player, recorder, metronome, monitor...)
http://perso.wanadoo.es/plcl/alsautil.tar.bz2

More examples, for Kylix and FreePascal:
http://perso.wanadoo.es/plcl/

HTH

nowx.cc Thu Jan 16 22:08:59 2003 renamed from nowx.cc.old Thu Jan 16 22:11:17 2003 +5 -4
@@ -64,14 +64,14 @@
   wxMidiOutput outport(sequencer);
   wxMidiQueue queue(sequencer);
   int x;
-  for (x = 0; x < 400; ++x)
-  {
-    queue.NoteOn(outport, x, 127, x);
-  }
   cout << "Queue will start in five seconds" << endl;
   sleep(5);
   cout << "Starting queue" << endl;
   queue.StartQueue();
+  for (x = 0; x < 400; ++x)
+  {
+    queue.NoteOn(outport, x , 127, x);
+  }
   while (1) {
     sleep(1);
   }
@@ -181,6 +181,7 @@
   snd_seq_queue_tempo_set_ppq(tpo, 128);
   snd_seq_set_queue_tempo(m_drv.GetAlsaSeq(), m_queue, tpo);
   snd_seq_queue_tempo_free(tpo);
+  snd_seq_drain_output(m_drv.GetAlsaSeq());
 }
 
 void wxMidiQueue::StartQueue()

-------------------------------------------------------
This SF.NET email is sponsored by: Thawte.com
Understand how to protect your customers personal information by implementing SSL on your Apache Web Server. Click here to get our FREE Thawte Apache
Guide: http://ads.sourceforge.net/cgi-bin/redirect.pl?thaw0029en

#2 lore raw
Quoted 2 lines · Pedro Lopez-Cabanillas

In short: start the queue before sending events, add snd_seq_drain_output at end of SetTempo method.

...and then there was light! Er.. sound!

Now that it's working, I'm left again with conceptual questions. I was under the impression that I could put events in a queue, start it, stop it, and start it from the beginning again. Is that not the case? The events seem to leave the queue once sent.

Likewise, I was under the impression that queues handled sequencing events by timestamp if they arrived in non-sequential order. Is that so? Do I just need to stay ahead of the queue for this to work? Does that mean, I can't reliably send the queue all events for one voice, followed by all events for another voice?

Thank you, Pedro, for showing me how to fix my code. That was a huge help.

Signature · 8 lines
Brian


-------------------------------------------------------
This SF.NET email is sponsored by: Thawte.com
Understand how to protect your customers personal information by implementing
SSL on your Apache Web Server. Click here to get our FREE Thawte Apache 
Guide: http://ads.sourceforge.net/cgi-bin/redirect.pl?thaw0029en
#3 lore raw
Quoted 4 lines · Brian Victor

Likewise, I was under the impression that queues handled sequencing events by timestamp if they arrived in non-sequential order. Is that so?

Yes, the sequencer's priority queues automatically order the events enqueued by timestamp.

Quoted 3 lines

Do I just need to stay ahead of the queue for this to work? Does that mean, I can't reliably send the queue all events for one voice, followed by all events for another voice?

Because of memory sizes for the event pool, this depends on the number of events you want to enqueue. Of course you'll need to stay ahead of the queue or the event wil be emitted immediately (when T[scheduled] < T[queue head]).

Yes, you can enqueue all events for one voice followed by next voices as long as you do not exceed the size of the queue. In practice you'll enqueue the events for a (small) timeframe, eg. one bar, and let the sequencer handle the scheduling.

Frank.

Signature · 12 lines
+---- --- -- -  -   -    - 
| Frank van de Pol                  -o)    A-L-S-A
| [email protected]                    /\\  Sounds good!
| http://www.alsa-project.org      _\_v
| Linux - Why use Windows if we have doors available?


-------------------------------------------------------
This SF.NET email is sponsored by: FREE  SSL Guide from Thawte
are you planning your Web Server Security? Click here to get a FREE
Thawte SSL guide and find the answers to all your  SSL security issues.
http://ads.sourceforge.net/cgi-bin/redirect.pl?thaw0026en