Skip to content

Midi looping, speed play, cut preview - #2378

Closed
Paul-Licameli wants to merge 9 commits into
audacity:masterfrom
Paul-Licameli:MIDI-looping-and-speed-play
Closed

Paul-Licameli wants to merge 9 commits into
audacity:masterfrom
Paul-Licameli:MIDI-looping-and-speed-play

Conversation

@Paul-Licameli

@Paul-Licameli Paul-Licameli commented Jan 4, 2022 •

Copy link
Copy Markdown
Collaborator

Resolves: #2359
Resolves: #2081

Fix the cooperation of MIDI with the adjustable looping region, and also make it work with the speed slider and cut preview.

These kinds of play should now remain synchronized with any audio tracks that also play simultaneously.

Change of speed means MIDI events like note-on and -off are more rapid, but pitch will be the same.

Still to do: make MIDI work with scrubbing too.

  • I signed CLA
  • The title of the pull request describes an issue it addresses
  • If changes are extensive, then there is a sequence of easily reviewable commits
  • Each commit's message describes its purpose and effects
  • There are no behavior changes unnecessary for the stated purpose of the PR

Recommended:

  • Each commit compiles and runs on my machine without known undesirable changes of behavior

@Paul-Licameli
Paul-Licameli force-pushed the MIDI-looping-and-speed-play branch from 94ff670 to 16c48a7 Compare January 4, 2022 22:22
@Paul-Licameli
Paul-Licameli requested a review from pietro68 January 5, 2022 10:12
@Paul-Licameli
Paul-Licameli force-pushed the MIDI-looping-and-speed-play branch 2 times, most recently from ad4d78f to 86c095e Compare January 10, 2022 11:55
@Paul-Licameli
Paul-Licameli force-pushed the MIDI-looping-and-speed-play branch 3 times, most recently from e51f0b5 to 371b056 Compare January 22, 2022 22:42

@pietro68 pietro68 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quite honestly this code is beyond me and I would need quite some time to understand what is going on here.
I did some QA in the sense that I tried looping and speed changes on a midi file and it seems to work.

One thing I noticed (out of the scope of this PR) is that although I selected my laptop speakers as playback device, a wave track will be played through them like it should, but the midi file gets played through my wireless headphones. This happens also in the current released 3.1.3

... of AudioIoCallback.

This is done to avoid dependency cycle problems.  PlaybackSchedule::TimeQueue
will need this array but should not need AudioIoCallback to get it.  So
AudioIoCallback can still have PlaybackSchedule with its TimeQueue as members.

AudioIOExtensions does need PlaybackSchedule to initialize itself, but it can
treat that as an opaque type.
... Which will allow the same division of labor between threads for MIDI play
as for audio.  A producer thread without low-latency constraints decides what
to play, and produces a message; the low-latency consumer thread will dequeue
the message and interpret it quickly.
... This will allow the main thread to detect when it is safe to destroy state
... Getting the use of the atomics right, and a forward-list as an unbounded
queue of information between them.

Note that the communication is lock-free and the low-latency consumer side does
no free store allocation or freeing.
... Which will be consumer-thread side, that won't make the decisions about
which parts of the track to play.

They stop using the function MidiLoopOffset(), which will be eliminated.

Instead some information is stored in the iterator, and this may need updating
by the producer even after the consumer has made some use of the iterator.  So
use atomics in the iterator.
... They may be shared across successive entries, but must not be shared where
there is a discontinuity in movement of the play head.

The consumer will later use those iterators.

The allocation in make_shared will not happen in the low-latency thread.
... as consumer-side usage of the iterators in the queue replaces the old
system for computing the time stamps for MIDI events.
@Paul-Licameli
Paul-Licameli force-pushed the MIDI-looping-and-speed-play branch from f807dd4 to e4a4712 Compare February 27, 2022 01:25
@LWinterberg

Copy link
Copy Markdown
Member

This PR has been sitting in approved for quite some time now, can it be merged?

@Paul-Licameli

Copy link
Copy Markdown
Collaborator Author

This PR has been sitting in approved for quite some time now, can it be merged?

Would likely need a difficult rebasing and re-review for 3.3

Which I would like to see happen

@LWinterberg LWinterberg added this to the Audacity 3.4 milestone Mar 10, 2023
@ianalarina ianalarina removed this from the Audacity 3.4 milestone Nov 6, 2023
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

Successfully merging this pull request may close these issues.

Adjustment of loop play bounds is ignored for MIDI playback MIDI playback starts from beginning regardless of cursor position

4 participants