Record audio of unknown length
-
@ustk thanks, I almost understand the example ;-) Could you please help me out to get the output of the buffer into the file player in scriptnode?
-
@tomekslesicki when I call
inline function reconstructFromAccumulator() { outputBuffer = Buffer.create(g_accumulator.length * Engine.getBufferSize()); for (b in g_accumulator) { local b_idx = g_accumulator.indexOf(b); // not proud to iterate over each sample but I haven't found a way to "referTo" when target buffer is bigger than reference... for (i=0; i<b.length; i++) { local idx = b_idx * b.length + i; outputBuffer[idx] = b[i]; } ScriptFX1AP.setFile(outputBuffer); } g_accumulator.clear(); }
an object gets assigned to the file player node but the waveform isn't drawn and it doesn't play. I guess it's something obvious I can't get my head around...?
-
@tomekslesicki That's because
outputBuffer
is not an audio file yet, but just raw signal data in a buffer.
It has to be written in an audio file prior loading.
You should be able to get this done using theFileSystem
to create a file at the location you want, andFile.writeAudioFile
for dumping the buffer into it.Now, I wonder if this can be done internally using only a registered audio file or if it has to physically live on the hdd. @Christoph-Hart ?
-
@tomekslesicki here you go
HiseSnippet 2436.3oc6X0saaibElx1LIV6OsYwdQubfQApbhqhTrWmD3lD4e23tw1BVtFKfgqwHxgRyZxYXGNzxZCBvdQunuE8t9TzK5qReCxaP64LCoHkshisa1E6BTmXCxYNyLem++F1VI8XIIRkSkpGLLl4T4Sc6LTn6udeJW3r8FNU9b2cnIZlhXGZsgwzjDluSkJS+03.UlcFGyOu6kqQCoBOVwPNNGJ4drWyi35hQa25a3ggaQ8YGviJI8Rs11SJVWFJSA7LsaCmXp2ozdrconXS457JZRemJOvswWsLi8jEC78oKtn+xKu7yd5yV5YMoAMVh1s4xOaoGuzSd7SeRfSk6roOWKUczTMKwoxLqI8G1oubfvd.GxS3cCY3KMc5.mrc3sjg9nJhi5rdedne6bCUhiSE21ElsoslsuzcGtOez3EluesYBRwJJa.qL03va5wfWyxvqQI3MAHUoDjbsP59tc7T7XcwLHd9D2sEf2LfB9oxPY2znUS84xs3gHRbqTA7H1MvYpu4dtqKgkIz0inmx1RAuLZapsbiFKPf+L+JUqBNvDM4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zRqL6POu38+I3RaSU.ZgK6f68LidCbgEKsfFPwxGMVK3lRwXVYYJMcNkMvZwJOp8qch403GhXGzTeoSXCV.MMTeowct4PCfwMBZ2AXtouDjd2KmLjd2K+.PZoVWBRs96SvZAY0uWH8qb2WJ0aoXvMCEdCu.19g2zZhXCF24ifmr0+96+qWg45SbQbsOVJ41Xyv370jxSinl5V+O2O5d1Iuq6tRdByTQ4KrOS9Zl.+BJRUyOFec83q8WWuxzW0GGu4s7iiOyO6933+B3pQi886mMGic3Xc1MEmwBgXsrXlrP27QGOlYGoPl2prHLYeFzkuWO134HSRgVUqgReEi7ks1mExnIEwQ+1+QqWCcFoJS8wamsn402VbU9qeiqEtDLPm7+uR6OOuR6OITM+o3LhndJ4IdVF5Xb58Li.5svPnZV2cv2IMu7mOJBpxchm23a0kV3iusKbwa6BW51tvu51tvkusK7I21E9zO7BwlPqlpkQ1TSf8Q6MsrTqrofBQ4lLBm+KKIRO0
I improved a few other things as well. There are still some flaws but it gets the job done
-
@ustk Epic, thank you! Your previous suggestion got me to where I wanted to be already, but this improves it further :-) I really appreciate it! What should I modify to get a stereo input?
-
@tomekslesicki said in Record audio of unknown length:
What should I modify to get a stereo input?
just push a second buffer in the accumulator
g_accumulator.push([Buffer.create(bl), Buffer.create(bl)]);
then write the buffers
channels[0] >> g_accumulator[g_accumulator.length-1][0];
channels[1] >> g_accumulator[g_accumulator.length-1][1];
and modify the loop in
reconstructFromAccumulator()
to account for this 2D array -
@ustk sorry for being a little bit immune to wisdom, but I got stuck at this part:
and modify the loop in reconstructFromAccumulator() to account for this 2D array
Thank you for your patience!
-
@tomekslesicki try to create a blank project with a simple 2D array and iterate over it with imbricated loop (you'll find a lot of content for doing so)
Once you get that done, we'll try to integrate buffers -
@tomekslesicki Alright so I updated again
- Stereo recording
- Dropped that nasty sample iteration for a real man buffer reference copy (15-20 times faster)
HiseSnippet 2924.3oc2Zs0TajbEdDvXao8RVuwOjG6hJUEgWhPxvhsKp0V.FrIgKpPrd2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Wh8ShYbJ0gse1QvEooMyMY1mAY761kMr+xjXnUUJHLXNk6zbeF9tCxso94+klaCYIoRcrxqlrnwEWVbd5qelsAtDznm7ehd6GUyrqgFmu1w6UuI5Kc.j2oJ+VYuras4+SyeY2FBDjx4E1DyXCIzKR3aF5pYr9tliEX869gs.OJoBJ7jJGU7O80ko8LWXaDjk9vwlFCKgudxOf.r1j3CG.+Y1snu2LHthdp21fWa6s2buDPBehjg9FmKH+au7N+0GuleD5vgQ9xKozLN4O7O9mOFqoYqbe6l+oleC8DFdo9IEdkwtay5BmYQJGvBiDsGvGJWX6Pn50dPavCWozcZh+kJrAmBRD2haRqdP1u877hYpg1FXaOPX9quYcrE+hCtUWNzKl4B8KRe89wJQXJCn6xBqu0zbzKrWdoZvWdeA96GtN7qE2654YqqubyScAMW+oZKgLUNZS7+3NXFDmYD9eSD+iwE07+KmQH0QJNxwbGZnE5szT.YKWekGks2AelzX7WWTHzGxQNNCuUisv6cUW3hW0EtzUcge4UcgKeUW38upK7Au6EhsItZxKsGx2YYsSqMLgJKkEmtzzV+a71R2JI
This is now a serious candidate for the snippet waiting room
-
@ustk genious, thank you!