Loop sequencer
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é
Quoted 3 lines · Guillaume Dupré
Hello
I try to program a loop midi sequencer with libasound . For the moment, I have this :
Hi!
[...]
Quoted 1 line
sleep(4) ;
use snd_seq_sync_output_queue() instead.
Quoted 3 lines
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 .
I guess there is no loop helpers in alsa-lib. You must make your own.
Check how other looping software is doing. I think you could do something like a function that receives a loop sequence (array of events sorted by time), a time (or tick) and a max time or max events.
int dump_loop(events[], base_time, max_time);
This function should put the appropiate event from the events[] based on the time frame and up to the max_time or max_events.
HTH,
Signature · 3 lines
Aldrin Martoq Episodio 002 (Lunes 24 Marzo)! http://aldrinvideopodcast.podshow.com/