Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mplay randomly drops midi notes #355

Open
jasonlevine opened this issue Mar 5, 2019 · 9 comments
Open

mplay randomly drops midi notes #355

jasonlevine opened this issue Mar 5, 2019 · 9 comments

Comments

@jasonlevine
Copy link

jasonlevine commented Mar 5, 2019

Hi all,

I recently upgraded from 0.7.0 to HEAD and found that midi notes were being dropped constantly. It seems to happen when more than one note is played at a time. The notes that go missing appear to be completely random. When I play the same sequence of 4 note chords over and over again, different notes are missing each time. It rarely plays all four notes, but it always plays at least one note. Most of the time at notes are missing. I have used midi monitor to make sure the problem wasn't happening in my midi host. Either way, the same code in 0.7.0 never misses a midi note. Not sure how to debug this one.

Jason

@benswift
Copy link
Collaborator

benswift commented Mar 7, 2019

Hi Jason, that's a bummer. Are you using the portmidi (which is sortof the default, or at least it's in external/ rather than contrib/) or RTMidi? The midi stuff hasn't changed in a long time - in fact I don't really think it's different between now and 0.7.0.

Which OS are you using? And if Windows, do you know which midi backend you're using?

One other thing to try as a workaround is to us a smaller --frames parameter at extempore startup - sometimes that can help. Although it's not a fix, I'll admit that.

@CastixGitHub
Copy link

CastixGitHub commented Sep 11, 2020

This also happens with CC messages

as ben suggested I lowered the frames to a quarter of default, but didn't change the behaviour

doesn't happens with this example code:

(sys:load "examples/sharedsystem/midisetup.xtm")

(bind-func midi_cc
  (lambda (timestamp:i32 controller:i32 value:i32 chan:i32)
    (println "MIDI_CC :" controller value chan "timestamp:" timestamp)
    void))

gif of working example: (patchage is the thing with "wires", vbeybd the window with keyboard and slider, the upper knob is an example i'm writing)
out-1

instead, if I just do (sys:load "examples/sharedsystem/setup.xtm")
it receives some of the changes, but not them all (nevers gets to 0 or 1)

gif of non-working example:
out-3

@digego
Copy link
Owner

digego commented Sep 12, 2020 via email

@CastixGitHub
Copy link

Thank you Andrew

It's just that the printf call prints an "outdated" value
(I tried all of what you described, the mock dspmt and so on, didn't fix the issue, because it's just about print, not getting midi values (tested some audio and the value is correct, never skipped a note_on))
so if I put something like

(println)
(println  (ftod (aref MCC_ARR controller)))

just after (aset! MCC_ARR controller (/ (i32tof value) 127.0))

I see that the value I printed is right, meanwhile the one in printf is the previous one, that's why it seemed it did never reach 0 or 1 before.

how does that printf in-place work? I struggled for nothing at all :)

(referring to

(printf "\rMIDI_CC: %d %f %d (%s) %s" controller (ftod (aref MCC_ARR controller)) chan (get_analogue_synth_cc_name controller)
this printf call)

@digego
Copy link
Owner

digego commented Sep 14, 2020 via email

@necrostaz
Copy link

necrostaz commented May 21, 2021

Hi I got this issue too. First I decreased frames count from 8192 to 1024 (default) and things become much better. But sometimes notes were to short or completely drops. I found that function play-midi-note from portmidi sends midi-on event and then midi-off after time equal note duration. Sometimes midi-off events overlaps midi-on events of next notes and so we have drops. So I decreased time of midi-off event for one sample and all things seems to be well now.
(impc:aot:do-or-emit (define play-midi-note (lambda (time device pitch velocity duration channel) (callback time 'pm_send device *midi-note-on* channel pitch velocity) (callback (+ time (- duration 1)) 'pm_send device *midi-note-off* channel pitch velocity) )))

I know - it not a best solution, but it works for me. Hope it helps.

And I have no idea why frame count affects midi behaviour.

@benswift
Copy link
Collaborator

Thanks @necrostaz thanks for the tip---I'll have a look into it asap. What platform/OS version are you on?

@necrostaz
Copy link

necrostaz commented May 24, 2021

Hi @benswift I use Win10\x64, extempore 0.8.9 (btw it would be great to add --version switch to command line) and loopMIDI driver as midi transport. Also I use external audio interface Audient id4 set to 96kHz rate and 8192 buffer, but as I said - I decrease settings to 44100 and 1024

@benswift
Copy link
Collaborator

Hey, so sorry about the long delay in replying. May 24 (the day you left your comment) was actually the day I fell down the stairs at work and dislocated & broke my elbow. I'm on the mend now, thankfully, but still not 100%.

Anyway, good to hear you've found a (sortof) workaround.

Re: the --version switch, I do agree that that would be super helpful. Wouldn't be too hard to add.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants