Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ActionScript 3 - Sound File Vs. Programmatically Created Sound

For basic sounds, such as sine waves or white noise, which is considered less processor intensive: looping an .mp3 file or programmatically creating the sound?

My first though was that looping an .mp3 must be less involved than programming a sound, but after reading the documentation and considering the primitive nature of these sounds i'm not so sure.

Any thoughts?

like image 897
Chunky Chunk Avatar asked Dec 02 '25 02:12

Chunky Chunk


2 Answers

The number of CPU instructions per uncompressed sound sample is usually far less for decoding an mp3 than for algorithmically generating samples for most sounds more interesting than a square wave, especially if the actionscript interpreter and floating point math gets involved.

like image 105
hotpaw2 Avatar answered Dec 04 '25 13:12

hotpaw2


There is a well documented article on the adobe website about the sound manipulation: http://www.adobe.com/devnet/flash/articles/dynamic_sound_generation.html

It clearly depends on your needs, but looping an mp3 is quite easy. Generating a sound and looping over it seems a bit more complex even if it is feasible.

By the way, if you loop over an mp3 that is much easier to tweak the mp3 with an appropriated software. Just recompile and the updated mp3 will be played correctly.

M.

like image 34
poussma Avatar answered Dec 04 '25 11:12

poussma