AudioLoopPlayer rootNote
-
This post is deleted! -
I wish i had that answer to. I am also in a question loop on the audio loop player and auto detect. Sometimes it will be perfect than after a few samples it is off. I would really like a button to turn that feature off and have a default root note 60 at all times after a sample load. I have been working on this on and off for some time. The forum has some posts but not clear if anyone has gotten this to work through a broadcaster or through another script. I have tried several methods and played with the custom load sampler as well. I am looking for my result to be very simple to load a sample.
My newest idea to try (Still new to broadcaster concepts) is to see if i can step up listening for a sample to load and then trigger a default value of a knob connected to the rootnote of the audioloopplayer.
Wise ones of the forum we seek understanding!!! Thank you always.
-
There is a callback you can attach to an instance of AudioFile:
AudioFile.setContentCallback(var contentFunction)
This fires off whenever the AudioFile contents change.
So I think it would be something like:
// Get audio sample processor for your module here // get a reference to the AudioFile object for the audio sample processor here // attach the callback here, making sure the callback // Setup the callback to set the value of the root note for the module
-
@Orvillain Thank you for your response. This looks promising I will try this AudioFile.setContentCallback(var contentFunction). I have not used that one yet and the work flow makes sense. I will report back.
-
@WaterSpoon I tried to deactivate the pitch detection function in the Hise source code but I need to fix something now because nothing works anymore
-
@WaterSpoon Let me know if it works like that
-
@treynterrio I had also previously attempted the alter the cpp files to know avail. But I assumed it was just my lack of experience. I am still playing with the call back suggestion thank you again @Orvillain I feel like it will end up being something very simple and a foundational concept I did not know how to apply yet.
I will share it when I can get this working as I think this feature would open more creative projects for everyone.
Right now my work around is on the interface I created a knob linked to the rootnote control of the audioloopprocessor and set the default value to 59. Double clicking the knob sets the rootnote to 60. I have been back and forth messing with it. More to come.
-
Well as it happens, I have need to use the AudioFile.setContentCallback(var contentFunction)
function as well, and try as I might, it isn't working.I have a reference to my AudioSamplerProcessor, and I have a reference to the AudioFile within it. I can use AudioFile.setContentCallback() to attach the following function:
inline function audiofile_callback() { Console.print('callback attached'); }
But I never get my message printed. It is as if the callback never gets fired on sample load or start/end point change. Bearing in mind the docs say:
Sets a callback that is being executed when a new file is loaded (or the sample range changed).I would note that I am using AudioProcessor.setFile(xxxx) to load my audio file into the audio processor. I'm not using the AudioFile.loadFile() method.
But even if I do load my file that way, there is no change.
@Christoph-Hart any snippet for this so we can know how it is supposed to work?
-
If I do this:
Content.makeFrontInterface(600, 600); const var asp = Synth.getAudioSampleProcessor("Audio Loop Player1"); const var af = asp.getAudioFile(0); af.setContentCallback(function(){ Console.print("This is a content callback, there are many like it, but this one is mine."); });
It works. So that'll sort these guys out here I'm sure. Inside your callback you can just set the asp's root note property.
This also works for a brand new project using a Scriptnode Synthesiser with either a file_player node, or a SNEX node that has an AudioFile object attached to it. I just need to figure out how to work this into my existing project.
-
oooooo... interestingly.... if I try to assign the same callback function to multiple audiofile slots across multiple audiosampleprocessors, then the callback never gets assigned. If I assign it to just one of them... then it works.
IE:
This works fine:
inline function setup_processor_callbacks() { local current_processor = Synth.getAudioSampleProcessor("sampler_0"); local current_audiofile = current_processor.getAudioFile(0); current_audiofile.setContentCallback(function(x){ Console.print("This is a callback."); }); }
This does not:
inline function setup_processor_callbacks() { for (i = 0; i < pad_count; i++) { local current_processor = Synth.getAudioSampleProcessor("sampler_" + i); local current_audiofile = current_processor.getAudioFile(0); current_audiofile.setContentCallback(function(x){ Console.print("This is a callback."); }); } }
I thought the whole point of a callback was so you could easily attach it to multiple objects without having to duplicate code? This seems like a bug to me.
-
@Orvillain Thank you!!! This is great and it works to print to the console. I appreciate the suggestion and example!!! Blessings!!!
-
@Orvillain Great end to a long journey. i knew it would end up being a simple few lines of coding.
Here is what i got working!!!
This code will keep the root note set to 60 as new samples are loaded.
Content.makeFrontInterface(600, 600); const var asp = Synth.getAudioSampleProcessor("Audio Loop Player1"); const var af = asp.getAudioFile(0); af.setContentCallback(function() { asp.setAttribute(asp.RootNote, 60); Console.print("Root note set to 60."); });