Three Minim Questions
in
Core Library Questions
•
2 years ago
Hi, It's been quite some time since I've visited the forum here and boy have things changed.
I have three questions about Minim.
Question 1: Given the following statement
player = minim.loadFile(audioFile, bufferSize);
and assuming that bufferSize is 1024, this means that I have created an "array" of 1024 elements.
Now inside of draw() I have the following, for example:
for(int i = 0; i < player.bufferSize(); i++) {
float value = player.left.get(i);
// some code to draw something
}
So at the end of the for loop I have read through the entire buffer and hit the last line of code in draw() - at which point draw(0 executes again. My question is what is the trigger that causes the player buffer to be loaded with the next 1024 bytes of audio data? Is the buffer automatically reloaded when the end of the draw() function is encountered correct? If so, what happens if I don't have a draw() function (drawing offline as opposed to drawing to the screen)?
Question 2: How do I find out the number of bytes of data in the audio file (ie how many total "array" elements...)? All the lengths that I've found in the Minim doc relate to time (milliseconds).
Question 3: What is the best way to synchronize the end of the audio file with halting the drawing? I set the player to loop 1 time and then used the following as the last line of draw():
if ( !player.isPlaying() ) savepic();
Is there a better way?
Thanks.
I have three questions about Minim.
Question 1: Given the following statement
player = minim.loadFile(audioFile, bufferSize);
and assuming that bufferSize is 1024, this means that I have created an "array" of 1024 elements.
Now inside of draw() I have the following, for example:
for(int i = 0; i < player.bufferSize(); i++) {
float value = player.left.get(i);
// some code to draw something
}
So at the end of the for loop I have read through the entire buffer and hit the last line of code in draw() - at which point draw(0 executes again. My question is what is the trigger that causes the player buffer to be loaded with the next 1024 bytes of audio data? Is the buffer automatically reloaded when the end of the draw() function is encountered correct? If so, what happens if I don't have a draw() function (drawing offline as opposed to drawing to the screen)?
Question 2: How do I find out the number of bytes of data in the audio file (ie how many total "array" elements...)? All the lengths that I've found in the Minim doc relate to time (milliseconds).
Question 3: What is the best way to synchronize the end of the audio file with halting the drawing? I set the player to loop 1 time and then used the following as the last line of draw():
if ( !player.isPlaying() ) savepic();
Is there a better way?
Thanks.
1