How to resolve the algorithm Record sound step by step in the ChucK programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Record sound step by step in the ChucK programming language
Table of Contents
Problem Statement
Record a monophonic 16-bit PCM sound into either memory space, a file or array. (This task neglects to specify the sample rate, and whether to use signed samples. The programs in this page might use signed 16-bit or unsigned 16-bit samples, at 8000 Hz, 44100 Hz, or any other sample rate. Therefore, these programs might not record sound in the same format.)
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Record sound step by step in the ChucK programming language
Source code in the chuck programming language
// chuck this with other shreds to record to file
// example> chuck foo.ck bar.ck rec
// arguments: rec:
// get name
me.arg(0) => string filename;
if( filename.length() == 0 ) "foo.wav" => filename;
// pull samples from the dac
dac => Gain g => WvOut w => blackhole;
// this is the output file name
filename => w.wavFilename;
<<<"writing to file:", "'" + w.filename() + "'">>>;
// any gain you want for the output
.5 => g.gain;
// temporary workaround to automatically close file on remove-shred
null @=> w;
// infinite time loop...
// ctrl-c will stop it, or modify to desired duration
while( true ) 1::second => now;
You may also check:How to resolve the algorithm Integer comparison step by step in the Logo programming language
You may also check:How to resolve the algorithm Emirp primes step by step in the Factor programming language
You may also check:How to resolve the algorithm Speech synthesis step by step in the C# programming language
You may also check:How to resolve the algorithm Knapsack problem/Bounded step by step in the Swift programming language
You may also check:How to resolve the algorithm Literals/Integer step by step in the Ada programming language