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

Midi import: Tempo from MIDI file is overwritten by default tempo #96

Closed
schnitzeltony opened this issue Nov 14, 2017 · 17 comments
Closed
Labels

Comments

@schnitzeltony
Copy link
Contributor

Hi,

When importing a MIDI file, the tempo suggested by the file is overwritten by default tempo. On PC (fast) the effect is not visible but on RaspberryPi (slow) the imported tempo is displayed for a short while in toolbar(<1s) and then overwritten by the tempo set before in the session.

@rncbc
Copy link
Owner

rncbc commented Nov 15, 2017

hi,

could it be that some other JACK client has taken over or is messing up as jack-timebase master? or MIDI Clock input is enabled and something is overriding the current qtractor session tempo(BPM) ?

otoh. as a rule, a long ago established one and still, tempi (yes plural for tempo-map) of an imported MIDI standard file is effective if and only if it's the first on a brand new and empty session; if there are any prior existing MIDI track/channels in session, then all tempi from any additional MIDI file imports are simply ignored or overruled.

does any of the above make any sense on the behavior you're seeing?

cheers

@schnitzeltony
Copy link
Contributor Author

I am afraid not: To be sure I deleted Qtractor.conf. Then started nothing but qtractor (not even qjackctl) -> Initial tempo 120bpm.Then imported the file I'll send you by email (not here - I am not sure for copyright on that file). I expect 129bpm. As said: on slow RaspberryPi I see 129bpm for very short time and then it switches back to 120bpm.

Tried this also with 0.8.4 shipped with fedora - same.

Did some debugging: I set a breakpoint at qtractorMidiFileTempo::addNodeTempo and see one call with fTempo = 129 and iTick = 0. Checked in call stack down to qtractorTracks::addMidiTracks: iTrack = 1 so I'd expect this tempo on first track (iChannel is incremented at the beginning of the loop).

@rncbc
Copy link
Owner

rncbc commented Nov 15, 2017

it seems to set the tempo right if you import the .mid file into a location that is not the absolute beginning, given by the edit-head or left vertical line.

if the midi file is imported into the absolute beginning the of time-line then it looks like the initial tempo (of the file) is discarded and overruled by the current session tempo.

yep, this is not correct behavior: it's a dang bug and would start looking at https://github.com/rncbc/qtractor/blob/master/src/qtractorMidiClip.cpp#L470
for clues...

@rncbc
Copy link
Owner

rncbc commented Nov 16, 2017

as matter of fact, it is JACK transport that is messing with imported MIDI file tempi: if you turn off Transport > Mode to "None" or "Output" only, then things tend to work right.

so after all, the issue seems to point to a race condition over the JACK transport/timebase callback and the moment jack_transport_query() is called periodically (qtractorMainSession::slowTimerSlot()).

@schnitzeltony
Copy link
Contributor Author

Yeah it looked racy to me either. Tonight (with my hobby hat on) I will give this a try on PC and RaspberryPi and let you know. Thanks for taking care.

@rncbc
Copy link
Owner

rncbc commented Nov 16, 2017

should be fixed now with 0154eee
also merged into 'neonx' branch.
cheers

@rncbc rncbc changed the title Midi import: Tempo from from MIDI file is overwritten by default tempo Midi import: Tempo from MIDI file is overwritten by default tempo Nov 16, 2017
@rncbc rncbc added the bug label Nov 16, 2017
@schnitzeltony
Copy link
Contributor Author

Have tested on PC and Raspi: Thanks for fixing!

@schnitzeltony
Copy link
Contributor Author

Aargh - you opened the worm thingy (and I feel responsible :). 0154eee breaks at least mute.

To test:

  • Open a session (in my case only MIDI tracks)
  • Play session
  • Be sure that the volume is not too high before performing next step
  • Mute one track -> Ugly things happen

I switched back to previous commit (8bd65bd) and mute works again so it must be related to 0154eee.

@schnitzeltony schnitzeltony reopened this Nov 16, 2017
@rncbc
Copy link
Owner

rncbc commented Nov 16, 2017

what 'ugly' things? i've tested and didn't see any ugliness on muting a track or another.

@schnitzeltony
Copy link
Contributor Author

Sound distorts totally. Another thing I found (I am sure I've done it before without issue - will test): If you zoom in/out clip area sound is also distorted. As test case see sample session attached (again path and name for might Fluid3GM.sf2 need some alignment).

ExampleSession.zip

@schnitzeltony
Copy link
Contributor Author

Meanwhile tested but I was not precise: Zoom in/out horizontally clip area distorts while playing example session since last commit.

@rncbc
Copy link
Owner

rncbc commented Nov 17, 2017

can you retry on master head (0154eee) and uncheck View > Options... > General > Transport > Timebase ? does it make a difference?

and what about doing a git reset --hard 8bd65bd663647b26eb2b305abd384c4e2d9b66ea and rebuild it all from scratch?

@schnitzeltony
Copy link
Contributor Author

  1. master head ( 0154eee ) Timebase checked: Mute distorts / Zoom in/out clip area also distorts. Distortion sounds like many MIDI notes on/off in short time.
  2. master head ( 0154eee ) Timebase unchecked: Mute no distortion / Zoom in/out clip area also no distortion.
  3. full rebuild 8bd65bd : No distortion on either Timebase checked or unchecked.

@rncbc
Copy link
Owner

rncbc commented Nov 17, 2017

refactored in 61a00f2b

may you try again, with and without Timebase set ?

cheers

@schnitzeltony
Copy link
Contributor Author

Quick test on PC:

  • With or without Timebase set: no distortion
  • Midi import tempo correctly taken from MIDI file

So looks good from first glance.

Will start a build for RasberryPi with this change included, do further tests and let you know.

Why RaspberryPi: During my activities on qtractor I have learned: Things working perfect on PC can fail on RaspberryPi. It is much slower so things can behave complete different.

@schnitzeltony
Copy link
Contributor Author

It's not your problem but now auto-plugin-deactivation in neonx is broken. Auto monitoring does not work without auto-plugin-deactivation enabled Tomorrow is just another day...

@schnitzeltony
Copy link
Contributor Author

I did many imports and played around with them so I consider this solved. Thanks a lot for fixing this.

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

No branches or pull requests

2 participants