[chuck-users] Is it possible to get mp3 output instead of wav?
radarsat1 at gmail.com
Fri Oct 3 11:48:48 EDT 2008
On Thu, Oct 2, 2008 at 6:18 AM, Kassen <signal.automatique at gmail.com> wrote:
> Hey, Manish!
>>> My first post here. I stumbled on chuck this morning and have not been
>>> able to take my hands off it.. its fun!! While going through the manual I
>>> found chuck can write a Wav file to disk, can it also write an .mp3 file? I
>>> searched through the chuck-users archives messages but found no direct
> Short answer; no. The thing is that compressed files like MP3 and so on are
> a lot more complicated then .wav, .aiff, and so on. These last come down to
> a simple train of numbers expressing the amplitude of the contained wave at
> points in time, MP3 on the other hand is more like a description of how to
> recreate the sound in a way that will seem (almost) the same to human ears.
> So; it's a lot more complicated and harder on the CPU to "record to mp3".
> Basically recording to MP3 comes down to figuring out what the wave would
> be, encoding that to MP3 and writing the MP3 to disc. This is not to say it
> would be impossible to do that in the future but it does explain why we
> don't have it.
> You can of course still encode the .wav to MP3 yourself in your favourite
> editor, then delete the .wav for easier storage or for sharing your sounds
> with your friends without cloging your whole connection with large files.
>>> Also, I was curious if chuck can read in from a mp3 file. If not, are you
>>> aware of a command line tool that can convert from mp3 to wav and then feed
>>> into chuck (that's assuming wav files can be chucked). One of the reasons to
>>> try something like above is to make my own karaoke files (20-30 of them),
>>> but all my songs are mp3. I was planning to use chuck to do some frequency
>>> filtering to achieve karaoke effect and then possibly add some computer
>>> generated sounds to create a mix.
> Right now I see two options. You could decompress your files to waves (for
> example VLC has a "transcode wizard" that will do this, WinAmp can be set to
> output to wave files instead of your soundcard and of course any decent
> audio editor can save to .wav) then load those in a SndBuf UGen for playback
> in ChucK.
> You could also get one of the various programs that can route audio between
> programs and link the output of your MP3 player to the input (adc) of ChucK
> for further realtime treatment. What program you use for this will depend on
> your OS. For Linux there is Jack, Mac has Soundflower... and for Windows I
> don't know for sure what the best choise would be because I have a soundcard
> that will do this for me so I didn't look into that too deeply.
> There is no such thing as directly sending a wave file to ChucK; you can
> either load the file in a SndBuf and tell it how and when to play back or
> you can send a audio stream into ChucK.
In Linux or OS X, you could also create a pipe called "output.wav" and
write the ChucK output to this file. Then start a process like 'lame'
which encodes this file to an .mp3. As long as it's able to keep up,
ChucK won't block and you'll get an mp3 file without writing a huge
intermediate wav file.
I don't really recommend it though because it'll strain your processor
for little real gain. On the other hand, I guess on a multi-core
machine that doesn't matter so much.
commands (tested on linux):
lame --preset 320 output.wav output.mp3 &
chuck awesomewicked.ck rec.ck:output.wav
More information about the chuck-users