automatically composite sound - php or something like that - GD library for sound?

482 Views Asked by At

I am looking for a way to accomplish the following: A user programs some drum loops in flash and is somehow able to download or save an mp3 of the loop.

I thought that the pattern could be composted on the server side. Then a link to the file is sent to the user.

I had thought there might be something like imageGD or imageMagick for sound out there?

Also, if it is possible for flash to generate something that the user could save on the fly? That would work too, but I am unaware of any such functionality in flash.

I suppose something could be done in processing, but I am totally unfamiliar with that.

How might this sort of thing might be accomplished?

3

There are 3 best solutions below

0
On BEST ANSWER

Take a look at SoX.

SoX is a cross-platform (Windows, Linux, MacOS X, etc.) command line utility that can convert various formats of computer audio files in to other formats. It can also apply various effects to these sound files, and, as an added bonus, SoX can play and record audio files on most platforms.

0
On

Check out this MP3 class.

I'm using it for a project that was deployed just today.

It can read MP3's, extract a part of them, and merge files, among other things, except it doesn't overlap sounds.

Provided you already have those sound pieces (drums, guitar, etc) and that you don't need overlapping, it seems this is what you're looking for.

2
On

If you have control over your server environment, I suppose you could use ffmpeg to do the job.

In your PHP code:

exec(escapeshellcmd("/path/to/ffmpeg -i /path/to/audiofile1.mp3 -i /path/to/audiofile2.mp3 -itsoffset 10 -i /path/to/audiofile3.mp3 -itsoffset 20 -acodec mp3 /path/to/outputfile.mp3"),$output,$status);

Notice that -itsoffset is the offset in seconds you want the audio file to be placed in. So this is not ideal if you want very minute control over the timing, but I don't know if you need that.