|
From: Chris B. <ch...@cn...> - 2010-04-19 15:49:11
|
On Sat, Apr 17, 2010 at 5:42 AM, TJF <tjf...@we...> wrote: > Hi, > > could anyone give me an advice, how to do this (s.b.)? My problem is, > that I cannot find commands like "sox_open_memstream_write" in the > documentation and I don't know how to command something like this (this > time on Win): > > sox.exe file.wav -t .s32 output_signed_32.raw rate -v -M 88200 > > ______________________________ > > Up to now I take the raw-file above and play it in my software using > rtaudio-API (basic functions like in playraw.cpp). Now I would like to > integrate libsox into the program to do this. That should be the way: > > - open file > - read entire file to memory > - upsampling (the line above...) -> NOT saving (writing to) file! > - playing upsampled raw-file from memory Take a look at source code package of sox. Look at: src/example5.c - how to read file into memory and then write it back out. src/example3.c - how to set up an effects chain and optionally add in the resample effect. src/example1.c - How to create your own custom "input" effect and "output" effect. These custom routines could read or write from memory. There is lots of ways to do all this so it really depends on what your application needs. The way you listed above, you need to reserve 2 times the memory so you can have pre-resample and post-resample versions of audio. I'd instead read from file, pipe threw effects engine to resample and instead of writing to an output file, use logic from example5.c to write to memory. Then you can play the audio file. Or you can just play while resampling using the "wavaudio" output format... Not sure your application or why you need to fully buffer before playing. Chris |