Everybody! This is important. In a few days, these forums will be moving over to using the totally sweet Discourse platform. To ensure this migration happens smoothly with no loss of content, these forums are currently in a read-only mode. I do apologize for the inconvenience.

There is never a good time to turn the forums off for an extended period of time, but I promise the new forums will be a billion times better. I'm pretty sure of it.

See you all on the other side in a few days, and if you have any (non-technical) questions, please e-mail me at kirupa@kirupa.com. For technical questions, try to find a tutorial that corresponds to what you are looking for and post in the comments section of that page.

Cheers,
Kirupa

Results 1 to 4 of 4

Thread: [AS3] Mp3 Compression Help

  1. #1

    [AS3] Mp3 Compression Help

    The game I'm working on is nearing completion, but when compressing our embeded assets we've run into several issues. Primarily, compressing the mp3s.

    The first issue is Flash's requirements. They don't seem to be well documented at all. After a lot of digging, I discovered the requirement for an mp3's frequency to be a multiple of 11.025 khz, which was how we were able to use mp3s at all.

    Even taking that into account, however, every sort of optimization I tried either 1) made the mp3 sound incredibly distorted, 2) failed to compile, or 3) made the compiler act like it was compiling forever and never finish.

    I'm using FlashDevelop for the game, and for mp3s we've used Audacity and MP3 Quality Modifier.

    This is our first game, so since this is a pretty critical and common task, I'm hoping someone with more experience can point out where we're going wrong. Googling for hours has yielded almost nothing helpful.

  2. #2
    No one can help?

  3. #3
    I'm interested in this as well, as I've run into the same problem and didn't have time to solve it, before the game needed to ship (client work). How do you import your sounds? By using Flex annotations?

    Far as I can tell, is that the best approach to compression, is to use programs that are designed to do it and import the compressed file into Flash. I use Photoshop to compress images for example. By using Audicity it seems like you got that covered.

    At the moment I'm working with the sound buffer directly in a hobby project. I'm surprised to see that you need a multitude of 11.025 khz. The sound buffer needs to be filled with a bytestream and uses 44.1 * 2 * 4 per milisecond. That stands for:
    • 44100 samples per second, (44.1 khz)
    • 2 channels, left and right
    • 4 bytes per sample, as every sample is an integer, which gives a resolution of 2^32.
    So that would bring it at 44.1 * 2 * 4 * 1000 = 352800 bytes per second, or 344.53125 kilobyte per second. An odd bitrate to say the least. I suspect they don't use the whole range of values the integer provides and cap it at at some value to get a 320 kByte bitrate. This is just a suspicion though.

    That bieng said, I think most problems come from using a samplerate that differs from 44.1 khz. I don't think resolution is much of a problem as Flash could easily normalize the value and find the appropiate value within it's own resolution. I suspect (and this is still an untested hunch), that most problems stem from using a lower samplerate, as you'd need to fill in blanks. When the mp3 runs at 1/2 or 1/4 (I noticed that 11.025 is 1/4th of 44.1kHz) you can easily duplicate it, but running at 3/4 would have you choosing between two samples almost every converted sample.

    I hope this gives you some more insight, it did for me at least. I haven't checked if the soundbuffer used by the VM runs at this bit- and samplerate, or just the soundbuffer that is used by the API ,although the latter would make little sense to me.
    Last edited by TOdorus; April 1st, 2012 at 06:30 AM.

  4. #4
    1,391
    posts
    Registered User
    most of the time sound is going to be the biggest mem hog - along side bitmaps - when imported into Flash, Flash does a pretty good job of compressing the files during compile, but there is only so much it can do - if you have huge music tracks... you have huge music tracks - no way around that, except to stream them from an external source

    usually, i will change the sample rate AND the publish rate to 11.025khz - (in Audacity, on the bottom, and in the track drop down) - i'll also split a Stereo track, convert both right/left to mono and mix down - this will give you mono sound, but is often ok

    if the quality of the music is critical to your game, you might want to re-evaluate it - as we used to say in the Theatre business: "if the audience notices the scenery, the show must suck"

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Home About kirupa.com Meet the Moderators Advertise

 Link to Us

 Credits

Copyright 1999 - 2012