views:

122

answers:

6

I am interested in finding out if there exists a program or library which can perform the following task, and would be suitable for running as part of a server side process on a web site. (it's okay if it takes longer than the 200 milisecond maximum that is reasonable for a single page request-I can run it as an asynchronous process)

The task is this: I have as input a set of audio files, and I have some data about when each audio file should start playing in a timeline. The program should output an audio file which is a mix of the input audio, combined using the timeline data. That is, I want an audio mixer that operates in batch mode, and not in real time.

I've done some google searches, but came up a bit frustrated because I'm not exactly sure what I should be looking for. Most audio mixers seem geared towards real time applications like games, and I'm not sure how to find something that does this task as something like a command line utility- purely taking input, and producing output as fast as it can.

I hope this question makes sense.

edit: Someone commented about cSounds, and then deleted it. Can anyone tell me more about csounds? Is it relatively straightforward to do what I'm asking? keep in mind that my input sound files may be between 10-50 seconds long, and I'm not interested in pitch distortion.

How would you accomplish this in cSounds?

Is there anything other than cSounds that can do this sort of thing?

A: 

Something like PHP's OpenAL bindings?

Amber
I'm not so sure. That, again, has the look of an API that's meant to be used in real time. I'm not sure how "play" "pause" etc would be used in a batch mode.
Breton
There was a comment about cSounds here which seems promising. It looks a bit like overkill, but it's the only thing I've seen so far that has a mode that writes directly to an output file. It looks like a fun program in any case.
Breton
+2  A: 

If you are willing to consider running batch scripts as part of this process, you might find SoX useful. Its "mixer" and "remix" commands look like they might be helpful, although you would possibly need to render empty space at the start of sound files to handle offsets.

Ed Harper
+1  A: 

you should have a look at SuperCollider. maybe that would do the trick for you.

kent
That definately looks interesting, but it's another real time API. Is there something you know about it that I couldn't find out? Does it do "offline" batch mode jobs?
Breton
A: 

You are probably getting alot of suggestions towards real-time audio solutions because of the way you have phrased your question:

The program should output an audio file which is a mix of the input audio, combined using the timeline data.

"input audio" is very vague. to me it sounds like a live input stream (like a microphone). If you are not dealing with live i/o streams at all, then yes, CSound would be a likely candidate. there are plenty of CSound tutorials online, so fire up google...

kent
"I have as input a set of audio files", does that really imply live input streams?
Breton
I also say "Batch mode, *not* realtime" "Server side process", "command line utility".. I honestly don't know how I can be much clearer. Do I need to draw a diagram?
Breton
then why don't you just write it in C/C++?
kent
Because I don't know the first thing about mixing audio, so I'd rather use a library written by someone who does, if one exists.
Breton
+1  A: 

You can definitely use csound for this, and it could be implemented a number of ways. Unfortunately, my still fairly nascent study of csound has been more involved with audio synthesis and algorithmic composition than sampling and processing, so I can't offer suggestions for a robust implementation.

However, I would guess that your project's orchestra file (the part of a csound program that contains audio synthesis and processing information, contained in modules called instruments) would involve the soundin opcode, which reads from an audio file, and then it would scale the amplitude of various streams and mix them before passing to output.

The timeline would probably be handled in the score file (the part of a csound program that handles initialization of instruments and function tables), which would translate your timeline data into playback timing.

You might also look up csound's GEN01 subroutine, which reads audio data from a file into a function table.

ninly
Welcome to stack overflow. can I ask how you found my question?
Breton
Thanks for the welcome, SO has been great so far.After I signed up, I did a few searches for audio-related stuff and csound in particular. It's something I've been very interested in, so I was curious to see if there was any related discussion on the site.
ninly
A: 

You might look at the BASS Audio Library. I'm unable to see if it can mix faster-than-real-time, as it's blocked at the firewall, but I've found it friendly to use in the past.

Dean J