[alsa-devel] Loop sequencer

Guillaume Dupré gui.dupre at gmail.com
Fri Mar 28 08:26:01 CET 2008


Hello

I try to program a loop midi sequencer with libasound .

For the moment, I have this :

#include <alsa/asoundlib.h>
#include <unistd.h>

using namespace std;
int main()
{
    int aa;
        snd_seq_t* seq;
        int port,port2, queue;
        snd_seq_queue_tempo_t* tempo;
        snd_seq_event_t ev;
        snd_seq_open(&seq, "default", SND_SEQ_OPEN_DUPLEX, 0);
    snd_seq_set_client_name(seq, "monprog");
        port = snd_seq_create_simple_port(seq, "port1",SND_SEQ_PORT_CAP_READ
| SND_SEQ_PORT_CAP_SUBS_READ,SND_SEQ_PORT_TYPE_APPLICATION);
        queue = snd_seq_alloc_queue(seq);
    //TEMPO
        snd_seq_queue_tempo_alloca(&tempo);
        snd_seq_queue_tempo_set_tempo(tempo, 60000000 / 120);
        snd_seq_queue_tempo_set_ppq(tempo, 4);
        snd_seq_set_queue_tempo(seq, queue, tempo);

       snd_seq_connect_to(seq, port, 130, 0);

       snd_seq_start_queue(seq, queue, NULL);
  // write 2 notes
        snd_seq_ev_clear(&ev);
        snd_seq_ev_set_subs(&ev);
        snd_seq_ev_set_source(&ev, port);

        snd_seq_ev_schedule_tick(&ev, queue, 0, 0);
        snd_seq_ev_set_note(&ev, 0, 60, 127, 3);

        snd_seq_event_output(seq, &ev);

        ev.time.tick = 4;
        ev.data.note.note = 67;
       snd_seq_event_output(seq, &ev);

        snd_seq_drain_output(seq);

sleep(4) ;

        return 0;
}

It works, no problem .
But now, I want to do a loop with my two notes .
I searched on the Internet but I didn't find .

Thanks

Guillaume Dupré


More information about the Alsa-devel mailing list