Trying to figure out how it might be possible to record a clip into an audio clip slot for a specified number of bars.
A dumb hack idea would be to use the Task and do some sort of math to calculate time in relation to bpm and fire off an event right before the clip end. this would trigger play() on the clipLauncherSlot. then bitwig would stop recording the clip and go to playback right on time.
Another idea would be to use the cursorClip and try to derive data out of that. not sure if the cursor clip works while recording audio tho.
And last idea would be to combine the first idea and get the time of the transport when pressing record and on updates of the transport position compare until it is time to press play again. I'm just concerned by doing this i'm going to get a lot of callbacks into the Javascript and will slow down performance of the system.
what are your thoughts on this?
Recording a clip for a specific amount of time?
- KVRist
- 393 posts since 12 Apr, 2020
----------------------------------------------------------------------
/CTRL → http://slashctrl.io
Music & mixes → http://soundcloud.com/kirkwoodwest
/CTRL → http://slashctrl.io
Music & mixes → http://soundcloud.com/kirkwoodwest
- KVRist
- Topic Starter
- 393 posts since 12 Apr, 2020
ok... this is what i got so far... using #3 idea. some of the code snippets here that i put in my TrackHandler.
init to mark position as interested. this causes the transport position to update the flush function every update.
When i launch the clip i store off the time index... I'm using the default BeatTimeFormat... honestly not sure how to change that.The lack of code examples in the api reference is my weakness but i get along by searching through driven by moss source code. 
This is fired when i queue the clip for record.
Note: If the clip is not recording or being queued, i reset the time_index to -1 so its not processed.
Then in my flush() I check the time index and compare the two values.
Then basically when the clip reaches 3 bars it tells the clips to launch again. Then launch queue begins, then starts playing. This clips is exactly 4 bars in length.
Seems to work well, i'd rather not have to process this on a flush() update everytime but I guess that it what that is for anyways.
I could not for the life of me figure out how to add an observer to the Transport.getPosition(). Didn't seem to be possible in the latest API or I just couldn't grok the documentation and couldn't find clear code examples.
Oh well. I hope I'm not litering this forum with random code bits but when something takes me an hour or so to figure out. I like to post it for someone else so they can figure it out in a fraction of the time.
init to mark position as interested. this causes the transport position to update the flush function every update.
Code: Select all
this.transport = host.createTransport();
this.transport.getPosition().markInterested();This is fired when i queue the clip for record.
Code: Select all
this.time_index = this.transport.getPosition().getFormatted();
Then in my flush() I check the time index and compare the two values.
Code: Select all
if (trackHandler.time_index != -1){
var pos = trackHandler.transport.getPosition().getFormatted();
var old_pos = trackHandler.time_index;
//Get the bars data out of the split.
var bars = pos.split(':')[0];
var bars_old = old_pos.split(':')[0];
var diff = bars - bars_old;
var clipsize_in_bars = 4;
if(diff >= clipsize_in_bars) trackHandler.launchSlots();
Seems to work well, i'd rather not have to process this on a flush() update everytime but I guess that it what that is for anyways.
I could not for the life of me figure out how to add an observer to the Transport.getPosition(). Didn't seem to be possible in the latest API or I just couldn't grok the documentation and couldn't find clear code examples.
Oh well. I hope I'm not litering this forum with random code bits but when something takes me an hour or so to figure out. I like to post it for someone else so they can figure it out in a fraction of the time.
----------------------------------------------------------------------
/CTRL → http://slashctrl.io
Music & mixes → http://soundcloud.com/kirkwoodwest
/CTRL → http://slashctrl.io
Music & mixes → http://soundcloud.com/kirkwoodwest
