ahlstromcj / sequencer64

A major reboot of Seq24. Current release 0.97.0 (2021-05-13), native JACK MIDI, Song recording, playlists, and a Windows/Qt version. For fresher code, see the Seq66 project. Note that trigger and mute-group-in-MIDI-file formats have evolved! Back up your work!
GNU Affero General Public License v3.0
235 stars 29 forks source link

note lengths recorded are fixed to grid when in MIDI sync instead of lengths played #179

Open gresade opened 4 years ago

gresade commented 4 years ago

I am using Alsa for MIDI. When I record with seq64 as clock master, the note lenghts are recorded as played. But when I switch to seq64 being the clock slave, the note length that is played is ignored, and the note length is fixed to the grid quantisation (not note lenght) setting. The keyboard used for recording is a separate midi device and is not the clock master when seq64 is the clock slave. I changed no settings in seq64 when going from clock slave to master and vice versa.

Also, when going back from clock slave to master again, there seems to be a lot of notes in the MIDI buffer that get played rapidly until the buffer is empty. I have to start/stop several times to get a clean start.

ahlstromcj commented 4 years ago

Okay, thanks for the report. I have a couple other issues and will likely get to them by the weekend at latest.

On Tue, Oct 8, 2019, 14:01 gresade notifications@github.com wrote:

I am using Alsa for MIDI. When I record with seq64 as clock master, the note lenghts are recorded as played. But when I switch to seq64 being the clock slave, the note length that is played is ignored, and the note length is fixed to the grid quantisation (not note lenght) setting. The keyboard used for recording is a separate midi device and is not the clock master when seq64 is the clock slave. I changed no settings in seq64 when going from clock slave to master and vice versa.

Also, when going back from clock slave to master again, there seems to be a lot of notes in the MIDI buffer that get played rapidly until the buffer is empty. I have to start/stop several times to get a clean start.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/ahlstromcj/sequencer64/issues/179?email_source=notifications&email_token=AB45LKEO5OPNK2GQPHHKUZTQNTDIBA5CNFSM4I6VHKM2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HQNLW6Q, or mute the thread https://github.com/notifications/unsubscribe-auth/AB45LKCGJQ4KZENXHSIVEWLQNTDIBANCNFSM4I6VHKMQ .

ahlstromcj commented 4 years ago

When you say you use Seq64 as an ALSA "clock master", how do you set that up? In Seq64, "master" is a JACK concept. Can you upload a screen shot of the setting? Thanks! Also, is the the Gtkmm interface or the Qt interface? Thanks!

gresade commented 4 years ago

I started Seq64 without launching Jack on Lubuntu (I did not start the Jack UI and server, but I can check if this is maybe launched in the background), with the -p --alsa options. I switched from Jack to Alsa because the seq64 clock in external sync has way less jitter using Alsa. In internal clocking also Alsa is quite jittery (this is a separate topic). I compiled the newest sources using the Gtkmm interface with all the standard settings, no changes were made after the git clone. The Midi channel recorded is on a seperate Midi input port using a midi-keyboard. I can send a screensot of the settings later on, as this is on a separate PC. Basically all the Jack flags in the settings are switched off (--alsa command line option). Also with these settings I can start seq24 up as a sync master with the play button. I am in "Live" mode and set the "fruity" interaction method. I hope this helps! Thank you for looking into this issue!

ahlstromcj commented 4 years ago

I'm still not clear how, when running in ALSA mode, how you set up ALSA clock master versus ALSA clock slave. This is probably something of which I am ignorant. Let me know how you set up or determine which ALSA clock mode. Thanks! (I like digging into this stuff... learn more that way).

gresade commented 4 years ago

Actually I did not "set up" the Alsa clock. I just ran the seq64 program with the --alsa option and got a clock running if I press play in seq64 (even if nothing is connected externally). And my external hardware midi sequencer (Akai MPC) can also start seq64 automatically when I press play on that external midi sequencer and seq64 syncs to the external sequencer speed very nicely. I only had to connect the external midi Sequencer Midi Input in seq64 in the settings. I thougt this should be the normal behaviour? If you need more special infos (e.g. command line output and config files), I can send you that.

ahlstromcj commented 4 years ago

Actually, Alsa clocking is something I haven't dug too deep into. Do you use a piece of hardware or software monitor it? Seq64 also builds a midiclocker app that I wrote long ago to help fix an issue involving a Yamaha consumer keyboard. Guess I should get back to speed on that!

On Fri, Oct 11, 2019, 12:51 gresade notifications@github.com wrote:

Actually I did not "set up" the Alsa clock. I just ran the seq64 program with the --alsa option and got a clock running if I press play in seq64 (even if nothing is connected externally). And my external hardware midi sequencer (Akai MPC) can also start seq64 automatically when I press play on that external midi sequencer and seq64 syncs to the external sequencer speed very nicely. I only had to connect the external midi Sequencer Midi Input in seq64 in the settings. I thougt this should be the normal behaviour? If you need more special infos (e.g. command line output and config files), I can send you that.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/ahlstromcj/sequencer64/issues/179?email_source=notifications&email_token=AB45LKCPP3UIMEN62SLBUFLQOCVK7A5CNFSM4I6VHKM2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEBASS5Y#issuecomment-541141367, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB45LKHJJLKZZBW2TPTQJUDQOCVK7ANCNFSM4I6VHKMQ .

gresade commented 4 years ago

Apart from seq64 all parts are external hardware devices, so I am using an Akai MPC hardware sequencer as a clock source, an Akai Sampler that is triggered by the Midi notes of seq64 and a Yamaha hardware midi keyboard to play and record notes into seq64. So it is all external midi equipment, no software instruments and no other midi software is running on the computer.

gresade commented 4 years ago

I am starting the sequencer like this:

`seq64 -p --alsa --verbose --no-jack-midi Forcing all-ALSA mode. [Deactivating JACK MIDI] [Reading rc configuration /home/none/.config/sequencer64/sequencer64.rc] [Filter-by-channel off] [Reading user configuration /home/none/.config/sequencer64/sequencer64.usr] Forcing all-ALSA mode. [Deactivating JACK MIDI] Found port system:announce of type non-virtual input system Found port Midi Through:Midi Through Port-0 of type non-virtual input device Found port Midi Through:Midi Through Port-0 of type non-virtual output device Found port USB Device 0x86a:0x01:USB Device 0x86a:0x01 MIDI 1 of type non-virtual input device Found port USB Device 0x86a:0x01:USB Device 0x86a:0x01 MIDI 1 of type non-virtual output device [a lot more midi I/Os...] [Initialized, running without JACK sync] 37 rtmidi ports created: Input ports (19): [0] 0:1 system:announce (system) [1] 14:0 Midi Through:Midi Through Port-0 [2] 20:0 USB Device 0x86a:0x01:USB Device 0x86a:0x01 MIDI 1 ... Output ports (18): [0] 14:0 Midi Through:Midi Through Port-0 [1] 20:0 USB Device 0x86a:0x01:USB Device 0x86a:0x01 MIDI 1 ...

[Input priority set to 1] [Output priority set to 1]`

The settings look like this: grafik

When I record synced to external Midi clock and record notes, they are all recorded with the snap to grid value for the length, no matter how long I hold the notes (I played some random stuff just for illustration): grafik

Apart from this issue, the timing in this sync mode is very good.

If I do not sync externally but just hit play in seq64, the notes are recorded correctly, but unfortunately the clock and playback of seq64 is a lot more jittery. grafik

ahlstromcj commented 4 years ago

I found a couple of issues in the code. First, perform uses the wrong scheduling function for the I/O threads, which are supported by pthreads. Also, I found an issue with the midi-clock calculation which affects PPQN other than 192. I have not yet figured out what's going on with recording only snapped values of the notes. Once I do, I will then test and then commit the new code to the midi_control branch.

A couple questions:

  1. What PPQN do you use? The default is 192, but can be changed in the [user-midi-settings] in the "usr" configuration file.
  2. Do you know the order of magnitude of the jitter in milliseconds?

Thanks! We will get this licked!

-------- gresade 13:27 Sat 12 Oct --------

I am starting the sequencer like this:

`seq64 -p --alsa --verbose --no-jack-midi Forcing all-ALSA mode. [Deactivating JACK MIDI] [Reading rc configuration /home/none/.config/sequencer64/sequencer64.rc] [Filter-by-channel off] [Reading user configuration /home/none/.config/sequencer64/sequencer64.usr] Forcing all-ALSA mode. [Deactivating JACK MIDI] Found port system:announce of type non-virtual input system Found port Midi Through:Midi Through Port-0 of type non-virtual input device Found port Midi Through:Midi Through Port-0 of type non-virtual output device Found port USB Device 0x86a:0x01:USB Device 0x86a:0x01 MIDI 1 of type non-virtual input device Found port USB Device 0x86a:0x01:USB Device 0x86a:0x01 MIDI 1 of type non-virtual output device [a lot more midi I/Os...] [Initialized, running without JACK sync] 37 rtmidi ports created: Input ports (19): [0] 0:1 system:announce (system) [1] 14:0 Midi Through:Midi Through Port-0 [2] 20:0 USB Device 0x86a:0x01:USB Device 0x86a:0x01 MIDI 1 ... Output ports (18): [0] 14:0 Midi Through:Midi Through Port-0 [1] 20:0 USB Device 0x86a:0x01:USB Device 0x86a:0x01 MIDI 1 ...

[Input priority set to 1] [Output priority set to 1]`

The settings look like this: [1]grafik

When I record synced to external Midi clock and record notes, they are all recorded with the snap to grid value for the length, no matter how long I hold the notes (I played some random stuff just for illustration): [2]grafik

Apart from this issue, the timing in this sync mode is very good.

If I do not sync externally but just hit play in seq64, the notes are recorded correctly, but unfortunately the clock and playback of seq64 is a lot more jittery. [3]grafik

— You are receiving this because you commented. Reply to this email directly, [4]view it on GitHub, or [5]unsubscribe.

References

Visible links

  1. https://user-images.githubusercontent.com/56317266/66707222-5963a000-ed3d-11e9-9b26-e09725511558.png
  2. https://user-images.githubusercontent.com/56317266/66707267-0807e080-ed3e-11e9-8761-d0b94e59650e.png
  3. https://user-images.githubusercontent.com/56317266/66707346-4520a280-ed3f-11e9-81a5-7a77f904c890.png
  4. https://github.com/ahlstromcj/sequencer64/issues/179?email_source=notifications&email_token=AB45LKA2Y6QJ5SLCV5V33ILQOIXJNA5CNFSM4I6VHKM2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEBCHWGY#issuecomment-541358875
  5. https://github.com/notifications/unsubscribe-auth/AB45LKHOKSOYEOXRDCYV6ITQOIXJNANCNFSM4I6VHKMQ

-- You will be imprisoned for contributing your time and skill to a bank robbery.

gresade commented 4 years ago
  1. I am using the default 192, I didn`t change the setting.
  2. I run a test at 300bpm and 32th notes. My MPC can trigger them easily without chokes and sounds like a "machine gun on" but way quicker triggering a short click sample. When I set up the notes in seq64 and run it as a slave to the MPC clock, the seq64 notes are similar in precision, especially I get not a single choked note when dialing from 100bpm up to 300bpm with the 32th notes. When I switch to seq64 creating its own clock (hit play in seq64 after hitting stop a few times to clear the buffer or whatever), I get chokes (lost or clearly delayed notes) where roughly above 130bpm is not really "usable" when playing 32th notes. This is quite an easy test to hear galloping, chokes and buffer issues in the midi chain, basically using very high MIDI traffic, but very deterministic note distance. So it is easy to hear, as the note distance starts to be perceived more as a pitch where deviations are quite easy to hear in contrast to timing perception without lots of training. But I could also record this as audio for analysis to measure the jitter. I guess something around 5ms or more to cause noticable hickups at around 130bpm already.
ahlstromcj commented 4 years ago

I think what is happening is that you many devices working at once (how many?)

Unfortunately, the MIDI engine in its current state polls, and it is possible for the earlier devices in the buss list to starve the later devices.

There is also a side issue that the JACK implementation can easily get the input buss number, but the ALSA implementation cannot (another user would like to be able to specify which buss/port is feeding MIDI control.)

I am doing some thinking about how to solve this. I will perform some experiments in a branch of Seq66, and if they work out I can backport at some point. Will probably bleed into next year before it is ready.

In the meantime, if you have the time and energy, can you make the portmidi version and see if that performs any better, as an experiment? No big deal if you don't want to do it.

-------- gresade 11:11 Sun 13 Oct --------

 1. I am using the default 192, I didn`t change the setting.  2. I run a test at 300bpm and 32th notes. My MPC can trigger them easily without chokes and sounds like a "machine gun on" but way quicker triggering a short click sample. When I set up the notes in seq64 and run it as a slave to the MPC clock, the seq64 notes are similar in precision, especially I get not a single choked note when dialing from 100bpm up to 300bpm with the 32th notes. When I switch to seq64 creating its own clock (hit play in seq64 after hitting stop a few times to clear the buffer or whatever), I get chokes (lost or clearly delayed notes) where roughly above 130bpm is not really "usable" when playing 32th notes. This is quite an easy test to hear galloping, chokes and buffer issues in the midi chain, basically using very high MIDI traffic, but very deterministic note distance. So it is easy to hear, as the note distance starts to be perceived more as a pitch where deviations are quite easy to hear in contrast to timing perception without lots of training. But I could also record this as audio for analysis to measure the jitter. I guess something around 5ms or more to cause noticable hickups at around 130bpm already.

— You are receiving this because you commented. Reply to this email directly, [1]view it on GitHub, or [2]unsubscribe.

References

Visible links

  1. https://github.com/ahlstromcj/sequencer64/issues/179?email_source=notifications&email_token=AB45LKBRRSHNYSWJVTAELWTQONQDXA5CNFSM4I6VHKM2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEBC4DBY#issuecomment-541442439
  2. https://github.com/notifications/unsubscribe-auth/AB45LKG5GMF5GE4MLS2E2C3QONQDXANCNFSM4I6VHKMQ

-- Q: What's the contour integral around Western Europe? A: Zero, because all the Poles are in Eastern Europe!

Addendum: Actually, there ARE some Poles in Western Europe, but they are removable!

Q: An English mathematician (I forgot who) was asked by his very religious colleague: Do you believe in one God? A: Yes, up to isomorphism!

Q: What is a compact city? A: It's a city that can be guarded by finitely many near-sighted policemen! -- Peter Lax