Fwd: Automated batch conversion of ck files to WAV
Hi there, I wrote this to Ge Wang on Twitter before but he's not been there since October, so I thought I'd better write here. I've used ChucK a few years ago and had quite some fun with it. I would like to use it as part of the game we are currently developing. The goal is to allow sounds to be customized to individual installations of the game, where they would then be played back by OpenAL to provide for positional 3D audio. As part of my prototyping, I wanted to write a simple Python script that is able to batch convert a stack of ck files to WAV, ideally sample precise (no leading or trailing silence). I thought that rec.ck would be perfect for achieving that but it seems I can't figure out a way to have recording end precisely when the main script is done playing, instead of recording indefinitely and waiting for abortion via the Ctrl+C key. Is there such a method? I'd be very thankful for advice. Cheers, Leonard -- Leonard und Sylvia Ritter, Duangle, GbR Ritter Altpieschen 9, 01127 Dresden Leonard.Ritter@duangle.com www.duangle.com Geschäftsführung: Sylvia Ritter, Leonard Ritter
I use this script, which allows scripts to register the durations they’re
going to play for:
http://pastie.org/8661565
I don’t remember whether I found it or wrote it, but I’ve modified it!
On Thu, Jan 23, 2014 at 3:45 PM, Leonard Ritter
Hi there,
I wrote this to Ge Wang on Twitter before but he's not been there since October, so I thought I'd better write here.
I've used ChucK a few years ago and had quite some fun with it. I would like to use it as part of the game we are currently developing. The goal is to allow sounds to be customized to individual installations of the game, where they would then be played back by OpenAL to provide for positional 3D audio.
As part of my prototyping, I wanted to write a simple Python script that is able to batch convert a stack of ck files to WAV, ideally sample precise (no leading or trailing silence).
I thought that rec.ck would be perfect for achieving that but it seems I can't figure out a way to have recording end precisely when the main script is done playing, instead of recording indefinitely and waiting for abortion via the Ctrl+C key.
Is there such a method? I'd be very thankful for advice.
Cheers, Leonard -- Leonard und Sylvia Ritter, Duangle, GbR
Ritter Altpieschen 9, 01127 Dresden
Leonard.Ritter@duangle.com
www.duangle.com Geschäftsführung: Sylvia Ritter, Leonard Ritter _______________________________________________ chuck-users mailing list chuck-users@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
-- Tom Lieber http://AllTom.com/ http://infinite-sketchpad.com/
Seems like the main script could signal an event when it is done (as
opposed to going into an infinite loop).
You could make a shared class that has a static Event member.
e.g.
*Shared.ck*
--------------
public class Shared {
static Event @ event;
}
new Event @=> Shared.event;
--------------
*main.ck http://main.ck*
-----------
// send audio to dac
Shared.event.signal();
-----------
*rec.ck http://rec.ck*
--------
// record audio from dac
Shared.event => now;
--------
Then you just have to load Shared.ck before the other two scripts.
Hope that helps!
Brian
On Thu, Jan 23, 2014 at 2:45 PM, Leonard Ritter
Hi there,
I wrote this to Ge Wang on Twitter before but he's not been there since October, so I thought I'd better write here.
I've used ChucK a few years ago and had quite some fun with it. I would like to use it as part of the game we are currently developing. The goal is to allow sounds to be customized to individual installations of the game, where they would then be played back by OpenAL to provide for positional 3D audio.
As part of my prototyping, I wanted to write a simple Python script that is able to batch convert a stack of ck files to WAV, ideally sample precise (no leading or trailing silence).
I thought that rec.ck would be perfect for achieving that but it seems I can't figure out a way to have recording end precisely when the main script is done playing, instead of recording indefinitely and waiting for abortion via the Ctrl+C key.
Is there such a method? I'd be very thankful for advice.
Cheers, Leonard -- Leonard und Sylvia Ritter, Duangle, GbR
Ritter Altpieschen 9, 01127 Dresden
Leonard.Ritter@duangle.com
www.duangle.com Geschäftsführung: Sylvia Ritter, Leonard Ritter _______________________________________________ chuck-users mailing list chuck-users@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
The easiest way to accomplish sample-precise starting/stopping is actually
inlining the WAV recording into your script. E.g.
dac => Gain g => WvOut w => blackhole;
"file.wav" => w.wavFilename;
// temporary workaround to automatically close file on remove-shred
null @=> w;
// your code goes here
SinOsc s => dac;
2::second => now;
// end of code
The WvOut will get shut down and closed whenever the script itself ends,
leaving you with a file thats exactly the running length of the script.
spencer
On Thu, Jan 23, 2014 at 1:22 PM, Brian Sorahan
Seems like the main script could signal an event when it is done (as opposed to going into an infinite loop). You could make a shared class that has a static Event member. e.g.
*Shared.ck* -------------- public class Shared { static Event @ event; } new Event @=> Shared.event; --------------
*main.ck http://main.ck* ----------- // send audio to dac Shared.event.signal(); -----------
*rec.ck http://rec.ck* -------- // record audio from dac Shared.event => now; --------
Then you just have to load Shared.ck before the other two scripts. Hope that helps!
Brian
On Thu, Jan 23, 2014 at 2:45 PM, Leonard Ritter < leonard.ritter@duangle.com> wrote:
Hi there,
I wrote this to Ge Wang on Twitter before but he's not been there since October, so I thought I'd better write here.
I've used ChucK a few years ago and had quite some fun with it. I would like to use it as part of the game we are currently developing. The goal is to allow sounds to be customized to individual installations of the game, where they would then be played back by OpenAL to provide for positional 3D audio.
As part of my prototyping, I wanted to write a simple Python script that is able to batch convert a stack of ck files to WAV, ideally sample precise (no leading or trailing silence).
I thought that rec.ck would be perfect for achieving that but it seems I can't figure out a way to have recording end precisely when the main script is done playing, instead of recording indefinitely and waiting for abortion via the Ctrl+C key.
Is there such a method? I'd be very thankful for advice.
Cheers, Leonard -- Leonard und Sylvia Ritter, Duangle, GbR
Ritter Altpieschen 9, 01127 Dresden
Leonard.Ritter@duangle.com
www.duangle.com Geschäftsführung: Sylvia Ritter, Leonard Ritter _______________________________________________ chuck-users mailing list chuck-users@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
_______________________________________________ chuck-users mailing list chuck-users@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
Thanks for the suggestions so far. These are interesting but they
require retrofitting scripts, so aren't universally compatible with
any ck ever written (which I hope you agree would be super super
helpful). Is there no solution that requires no change to the ck to be
converted?
On Thu, Jan 23, 2014 at 10:32 PM, Spencer Salazar
The easiest way to accomplish sample-precise starting/stopping is actually inlining the WAV recording into your script. E.g.
dac => Gain g => WvOut w => blackhole; "file.wav" => w.wavFilename; // temporary workaround to automatically close file on remove-shred null @=> w;
// your code goes here SinOsc s => dac; 2::second => now;
// end of code
The WvOut will get shut down and closed whenever the script itself ends, leaving you with a file thats exactly the running length of the script.
spencer
On Thu, Jan 23, 2014 at 1:22 PM, Brian Sorahan
wrote: Seems like the main script could signal an event when it is done (as opposed to going into an infinite loop). You could make a shared class that has a static Event member. e.g.
Shared.ck -------------- public class Shared { static Event @ event; } new Event @=> Shared.event; --------------
main.ck ----------- // send audio to dac Shared.event.signal(); -----------
rec.ck -------- // record audio from dac Shared.event => now; --------
Then you just have to load Shared.ck before the other two scripts. Hope that helps!
Brian
On Thu, Jan 23, 2014 at 2:45 PM, Leonard Ritter
wrote: Hi there,
I wrote this to Ge Wang on Twitter before but he's not been there since October, so I thought I'd better write here.
I've used ChucK a few years ago and had quite some fun with it. I would like to use it as part of the game we are currently developing. The goal is to allow sounds to be customized to individual installations of the game, where they would then be played back by OpenAL to provide for positional 3D audio.
As part of my prototyping, I wanted to write a simple Python script that is able to batch convert a stack of ck files to WAV, ideally sample precise (no leading or trailing silence).
I thought that rec.ck would be perfect for achieving that but it seems I can't figure out a way to have recording end precisely when the main script is done playing, instead of recording indefinitely and waiting for abortion via the Ctrl+C key.
Is there such a method? I'd be very thankful for advice.
Cheers, Leonard -- Leonard und Sylvia Ritter, Duangle, GbR
Ritter Altpieschen 9, 01127 Dresden
Leonard.Ritter@duangle.com
www.duangle.com Geschäftsführung: Sylvia Ritter, Leonard Ritter _______________________________________________ chuck-users mailing list chuck-users@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
_______________________________________________ chuck-users mailing list chuck-users@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
_______________________________________________ chuck-users mailing list chuck-users@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
-- -- Leonard und Sylvia Ritter, Duangle, GbR Ritter Altpieschen 9, 01127 Dresden Leonard.Ritter@duangle.com www.duangle.com Geschäftsführung: Sylvia Ritter, Leonard Ritter
maybe: call the file with something like rec.ck but with arguments. (my rec.ck is called wav_writer_wgain.ck)
chuck your_main_track.ck wav_writer_wgain.ck:duration:wav_name:gain
https://github.com/zeffii/ChucK/blob/master/ck_files/wav_writer_wgain.ck
where:
wav_name would be the desired output name
duration is seconds,
gain is 0.0 to 1.0
On Thu, Jan 23, 2014 at 10:34 PM, Leonard Ritter wrote: Thanks for the suggestions so far. These are interesting but they
require retrofitting scripts, so aren't universally compatible with
any ck ever written (which I hope you agree would be super super
helpful). Is there no solution that requires no change to the ck to be
converted? On Thu, Jan 23, 2014 at 10:32 PM, Spencer Salazar
The easiest way to accomplish sample-precise starting/stopping is
actually
inlining the WAV recording into your script. E.g. dac => Gain g => WvOut w => blackhole;
"file.wav" => w.wavFilename;
// temporary workaround to automatically close file on remove-shred
null @=> w; // your code goes here
SinOsc s => dac;
2::second => now; // end of code The WvOut will get shut down and closed whenever the script itself ends,
leaving you with a file thats exactly the running length of the script. spencer On Thu, Jan 23, 2014 at 1:22 PM, Brian Sorahan Seems like the main script could signal an event when it is done (as
opposed to going into an infinite loop).
You could make a shared class that has a static Event member.
e.g. Shared.ck
--------------
public class Shared {
static Event @ event;
}
new Event @=> Shared.event;
-------------- main.ck
-----------
// send audio to dac
Shared.event.signal();
----------- rec.ck
--------
// record audio from dac
Shared.event => now;
-------- Then you just have to load Shared.ck before the other two scripts.
Hope that helps! Brian On Thu, Jan 23, 2014 at 2:45 PM, Leonard Ritter
Hi there, I wrote this to Ge Wang on Twitter before but he's not been there
since October, so I thought I'd better write here. I've used ChucK a few years ago and had quite some fun with it. I
would like to use it as part of the game we are currently developing.
The goal is to allow sounds to be customized to individual
installations of the game, where they would then be played back by
OpenAL to provide for positional 3D audio. As part of my prototyping, I wanted to write a simple Python script
that is able to batch convert a stack of ck files to WAV, ideally
sample precise (no leading or trailing silence). I thought that rec.ck would be perfect for achieving that but it seems
I can't figure out a way to have recording end precisely when the main
script is done playing, instead of recording indefinitely and waiting
for abortion via the Ctrl+C key. Is there such a method? I'd be very thankful for advice. Cheers,
Leonard
--
Leonard und Sylvia Ritter, Duangle, GbR Ritter
Altpieschen 9,
01127 Dresden Leonard.Ritter@duangle.com www.duangle.com
Geschäftsführung: Sylvia Ritter, Leonard Ritter
_______________________________________________
chuck-users mailing list
chuck-users@lists.cs.princeton.edu
https://lists.cs.princeton.edu/mailman/listinfo/chuck-users _______________________________________________
chuck-users mailing list
chuck-users@lists.cs.princeton.edu
https://lists.cs.princeton.edu/mailman/listinfo/chuck-users _______________________________________________
chuck-users mailing list
chuck-users@lists.cs.princeton.edu
https://lists.cs.princeton.edu/mailman/listinfo/chuck-users --
--
Leonard und Sylvia Ritter, Duangle, GbR Ritter
Altpieschen 9,
01127 Dresden Leonard.Ritter@duangle.com www.duangle.com
Geschäftsführung: Sylvia Ritter, Leonard Ritter
_______________________________________________
chuck-users mailing list
chuck-users@lists.cs.princeton.edu
https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
The problem here is that the duration has to be known beforehand. The
batch conversion can't know how long these scripts are, and the
scripts themselves shouldn't be rigged to put that information
somewhere else. I'm amazed how difficult that appears to realize. I
went through the docs and I can find nothing of use.
On Thu, Jan 23, 2014 at 11:03 PM, Dealga McArdle
maybe: call the file with something like rec.ck but with arguments. (my rec.ck is called wav_writer_wgain.ck)
chuck your_main_track.ck wav_writer_wgain.ck:duration:wav_name:gain
https://github.com/zeffii/ChucK/blob/master/ck_files/wav_writer_wgain.ck where: wav_name would be the desired output name duration is seconds, gain is 0.0 to 1.0
On Thu, Jan 23, 2014 at 10:34 PM, Leonard Ritter
wrote: Thanks for the suggestions so far. These are interesting but they require retrofitting scripts, so aren't universally compatible with any ck ever written (which I hope you agree would be super super helpful). Is there no solution that requires no change to the ck to be converted?
On Thu, Jan 23, 2014 at 10:32 PM, Spencer Salazar
wrote: The easiest way to accomplish sample-precise starting/stopping is actually inlining the WAV recording into your script. E.g.
dac => Gain g => WvOut w => blackhole; "file.wav" => w.wavFilename; // temporary workaround to automatically close file on remove-shred null @=> w;
// your code goes here SinOsc s => dac; 2::second => now;
// end of code
The WvOut will get shut down and closed whenever the script itself ends, leaving you with a file thats exactly the running length of the script.
spencer
On Thu, Jan 23, 2014 at 1:22 PM, Brian Sorahan
wrote: Seems like the main script could signal an event when it is done (as opposed to going into an infinite loop). You could make a shared class that has a static Event member. e.g.
Shared.ck -------------- public class Shared { static Event @ event; } new Event @=> Shared.event; --------------
main.ck ----------- // send audio to dac Shared.event.signal(); -----------
rec.ck -------- // record audio from dac Shared.event => now; --------
Then you just have to load Shared.ck before the other two scripts. Hope that helps!
Brian
On Thu, Jan 23, 2014 at 2:45 PM, Leonard Ritter
wrote: Hi there,
I wrote this to Ge Wang on Twitter before but he's not been there since October, so I thought I'd better write here.
I've used ChucK a few years ago and had quite some fun with it. I would like to use it as part of the game we are currently developing. The goal is to allow sounds to be customized to individual installations of the game, where they would then be played back by OpenAL to provide for positional 3D audio.
As part of my prototyping, I wanted to write a simple Python script that is able to batch convert a stack of ck files to WAV, ideally sample precise (no leading or trailing silence).
I thought that rec.ck would be perfect for achieving that but it seems I can't figure out a way to have recording end precisely when the main script is done playing, instead of recording indefinitely and waiting for abortion via the Ctrl+C key.
Is there such a method? I'd be very thankful for advice.
Cheers, Leonard -- Leonard und Sylvia Ritter, Duangle, GbR
Ritter Altpieschen 9, 01127 Dresden
Leonard.Ritter@duangle.com
www.duangle.com Geschäftsführung: Sylvia Ritter, Leonard Ritter _______________________________________________ chuck-users mailing list chuck-users@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
_______________________________________________ chuck-users mailing list chuck-users@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
_______________________________________________ chuck-users mailing list chuck-users@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
-- -- Leonard und Sylvia Ritter, Duangle, GbR
Ritter Altpieschen 9, 01127 Dresden
Leonard.Ritter@duangle.com
www.duangle.com Geschäftsführung: Sylvia Ritter, Leonard Ritter _______________________________________________ chuck-users mailing list chuck-users@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
_______________________________________________ chuck-users mailing list chuck-users@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
-- -- Leonard und Sylvia Ritter, Duangle, GbR Ritter Altpieschen 9, 01127 Dresden Leonard.Ritter@duangle.com www.duangle.com Geschäftsführung: Sylvia Ritter, Leonard Ritter
participants (5)
-
Brian Sorahan
-
Dealga McArdle
-
Leonard Ritter
-
Spencer Salazar
-
Tom Lieber