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

/live/clip/get/notes should return all notes #87

Closed
wants to merge 7 commits into from

Conversation

StrongBearCeo
Copy link
Contributor

Fix #86

@StrongBearCeo
Copy link
Contributor Author

  • Should returns all notes even if they are pickup notes or notes out of loop range, out of clip start / end markers range
  • add api to get/set clip start / end markers

Copy link
Owner

@ideoforms ideoforms left a comment

Choose a reason for hiding this comment

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

Nice work! I've added a few questions and comments inline.

@@ -348,7 +348,8 @@ Represents an audio or MIDI clip. Can be used to start/stop clips, and query/mod
| /live/clip/fire | track_id, clip_id | | Start clip playback |
| /live/clip/stop | track_id, clip_id | | Stop clip playback |
| /live/clip/duplicate_loop | track_id, clip_id | | Duplicates clip loop |
| /live/clip/get/notes | track_id, clip_id | track_id, clip_id, pitch, start_time, duration, velocity, mute, [pitch, start_time...] | Query the notes in a given clip. |
| /live/clip/get/notes | track_id, clip_id, [from_time, from_pitch, time_span, pitch_span] | track_id, clip_id, pitch, start_time, duration, velocity, mute, [pitch, start_time...] | Query the notes in a given clip. |
| /live/clip/get/notes_range | track_id, clip_id, [from_time, from_pitch, time_span, pitch_span] | track_id, clip_id, min_start_time, max_end_time, min_pitch, max_pitch | Query the note range within a given clip. This is helpful in conjunction with /live/clip/get/notes to paginate and handle a large number of notes |
Copy link
Owner

Choose a reason for hiding this comment

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

I think a neater approach here would be just to have the single /live/clip/get/notes endpoint, with the final 4 parameters as optional (min_start_time, max_end_time, min_pitch, max_pitch) - would that work? That would then also have symmetry with /live/clip/remove/notes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ideoforms This api was added as a temporary fix for #88, before PR #89 was made

If there are too many notes, /live/clip/get/notes would fail. To address this, /live/clip/get/notes_range was introduced to determine the range of notes, and later /live/clip/get/notes could be called with optional parameters [from_time, from_pitch, time_span, pitch_span] for pagination purposes.

After merging PR #89, this API may no longer be required. However, it would still be beneficial to retain it for those who prefer to implement pagination.

Copy link
Owner

Choose a reason for hiding this comment

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

Thanks, will have another think on this once #89 is merged 👍

README.md Outdated
@@ -374,6 +375,10 @@ Represents an audio or MIDI clip. Can be used to start/stop clips, and query/mod
| /live/clip/set/loop_start | track_id, clip_id, loop_start | track_id, clip_id, loop_start | Set clip's loop start |
| /live/clip/get/loop_end | track_id, clip_id | track_id, clip_id, loop_end | Get clip's loop end |
| /live/clip/set/loop_end | track_id, clip_id, loop_end | track_id, clip_id, loop_end | Set clip's loop end |
| /live/clip/get/start_marker | track_id, clip_id | track_id, clip_id, start_marker | Get clip's marker start |
Copy link
Owner

Choose a reason for hiding this comment

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

Is this a floating-point value in beats? If so, could you add this to the help text in the usage column?
(I realise the same criticism applies to loop_start, loop_end etc - laziness on my part! feel free to amend all of the above)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ideoforms Updated

self.logger.info("Trying to get notes from an empty clip")
return ()
# Define default values
estimated_min_from_time = -16000
Copy link
Owner

Choose a reason for hiding this comment

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

default_min_from_time would be a better variable name here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ideoforms updated



# Check if parameters are provided in the params tuple
if len(params) == 4:
Copy link
Owner

Choose a reason for hiding this comment

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

Should flag an error if params has a length other than 4, as otherwise this would silently fail

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ideoforms In the else statement, default parameters were used. Would you prefer to throw an error instead?

@ideoforms
Copy link
Owner

I've just integrated support for this with the latest commit.

@ideoforms ideoforms closed this Nov 18, 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.

/live/clip/get/notes doesn't return all the notes
2 participants