alsaseq reorders my events

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi!

I nearly finished alsaseq driver for jackmidi, but have a problem.
Alsaseq reorders events in fast sequences, so note-on/note-off pairs got mixed.

The algorithm of sending is simple:

 		snd_seq_ev_schedule_real(&alsa_event, output_que, 1, &timestamp);
		frame_time = jack_frame_time(self->jack);
		frame_offset = event.time - frame_time;

		offset = ((long long)frame_offset) * 1000000000 / rate;
		timestamp.tv_sec = (long) (offset / 1000000000);
		timestamp.tv_nsec = (long) (offset % 1000000000);
 		snd_seq_event_output(self->seq, &alsa_event);


Here are the traces of what is going on:

jackmidi_alsaseq reads events from external midi interface and send
them to another midi interface.

Log shows what is being sent to alsaseq and when. Output format is:
[event] at [event.time] ([frame_time] + [frame_offset]) (+[offset]ns)

c0ff@ace ~/src/jack/alsamidi $ ./jackmidi_alsaseq
port created: in (20:0)  MIDI 1
port created: out (20:0)  MIDI 1
port created: in (24:0) USB Trigger Finger MIDI 1
port created: out (24:0) USB Trigger Finger MIDI 1
port_event: ADD 130:0
port created: out (130:0) aseqdump
90 4e 7f  at 86646526 (86622198 + 24328) (+506833333ns)
80 4e 40  at 86649830 (86622200 + 27630) (+575625000ns)
90 4e 7f  at 86654006 (86622201 + 31805) (+662604166ns)
80 4e 40  at 86656795 (86638582 + 18213) (+379437500ns)
90 4e 7f  at 86660562 (86638584 + 21978) (+457875000ns)
80 4e 40  at 86663502 (86638584 + 24918) (+519125000ns)
90 4e 7f  at 86666819 (86638585 + 28234) (+588208333ns)
80 4e 40  at 86669453 (86638585 + 30868) (+643083333ns)
90 4e 7f  at 86673078 (86654965 + 18113) (+377354166ns)
80 4e 40  at 86676430 (86654966 + 21464) (+447166666ns)
90 4e 6f  at 86678638 (86654967 + 23671) (+493145833ns)
80 4e 40  at 86680654 (86654968 + 25686) (+535125000ns)

We can see that all events go strictly in order (their frame_time is
monotonically increasing). Frame offsets are so big, because it runs
under jackd -d dummy -p 16384.

At the same time, aseqdump is hooked to jackmidi_alsaseq output port:

c0ff@ace ~ $ aseqdump
Waiting for data at port 130:0. Press Ctrl+C to end.
Source_ Event_________________ Ch _Data__
  0:1   Port subscribed           128:5 -> 130:0
  0:1   Port subscribed           128:2 -> 130:0
128:2   Note on                 0  78 127
128:2   Note off                0  78  64
128:2   Note off                0  78  64
128:2   Note on                 0  78 127
128:2   Note on                 0  78 127
128:2   Note on                 0  78 127
128:2   Note off                0  78  64
128:2   Note on                 0  78 127
128:2   Note off                0  78  64
128:2   Note off                0  78  64
128:2   Note on                 0  78 111
128:2   Note off                0  78  64

We see, Note on/Note off events are mixed.
Your suggestions, please.

Regards,
Dmitry.

P.S. Not wanting to start a flame war, but it is exactly the case, why
it's better for jackmidi driver to use as lower-level interface as
possible - less problems, more control.

P.P.S. alsa-devels, if you reply, please CC me, i'm not subscribed.

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Alsa-devel mailing list
Alsa-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.sourceforge.net/lists/listinfo/alsa-devel

[Index of Archives]     [ALSA User]     [Linux Audio Users]     [Kernel Archive]     [Asterisk PBX]     [Photo Sharing]     [Linux Sound]     [Video 4 Linux]     [Gimp]     [Yosemite News]

  Powered by Linux