Why not just concatenate the mp3 files into 1 file and play it as a
single sound track?
Ron
Abe Pazos wrote:
I don't understand how MP3 can take longer to start. Isn't the AIFF converted
to MP3 anyways by the IDE?
I'm preloading the MP3s from disk. I have generated them myself, so they are
trimmed until the last sample. Is there something that causes random delays
when starting MP3s?
To test the SOUND_COMPLETE event, I have created a very short sample (about 1
ms long) which acts as a metronome. I count when it has played 5 times, I play
a bass drum. The timing I get is quite random. So I don't understand how do you
get such perfect timing with your playlist class. Or maybe the problem is that
I'm looking for much more precision than what you needed for the music...
Here is my test code:
var pCounter:int = 5;
var pMetro:Sound = new metronome(); // 1 ms sample to act as a timer
var pChannel:SoundChannel = pMetro.play();
pChannel.addEventListener(Event.SOUND_COMPLETE, onComplete);
var pTime:int = getTimer();
function onComplete(tEvent:Event):void {
pChannel.removeEventListener(Event.SOUND_COMPLETE, onComplete);
pChannel = pMetro.play();
pChannel.addEventListener(Event.SOUND_COMPLETE, onComplete);
trace(getTimer() - pTime);
pTime = getTimer();
if (pCounter-- > 0) {
return;
}
pCounter = 5;
(new BassDrum()).play();
}
These are the times traced:
107 285 48 53 55 104 59 14 42 47 57 34 47 45 45 80 15 43 47 49 47
57 33 46 47 44 84 52 69 24 100 40 72 27 63 64 26 42 44 44 73 20
44 45 47 45 54 38 48 45 57 62 21 43 46 45 49 54 35 45 45 46 67
24 47 45 46 50 53 34 45 46 105 33 45 46 46 78 26 56 23 44 106 55
45 46 45 60 38 42 42 55 58 22 46 45 47 47 48 40 47 44 48 72 18 44
For what I've read, since the sound buffer size in XP is 2048 samples,
I should be getting a stable 46 ms delay.
The problem is there with and without trace().
If I can't fix it I will just use it like it is now. Anyways it adds a
less-machine more-human(drunk) like touch :)
Thanks for your reply,
Abe
As Jason mentioned, I've been going through the same process for a very
demanding client--one of the country's best music schools. My project is to
string together several audio clips, and make it sound like a real song, with
absolutely no glitches. Here's what I've found:
- Use AS3. AS2 isn't fast enough.
- Timers have limited usability, because they can be off by several
milliseconds. I tried that approach, and abandoned it after the prototype
stage.
- MP3's take too long to start playing, and tend to have glitches like pops
and clicks. A program Steven Sacks recommended, MP3Trim, helped, but still
didn't raise it to the professional level.
- Aiff files at 44.1/16 seem to be the best solution (wav files would probably
work too, but my client does all the asset prep on the Mac).
I wrote a playlist class that has methods to build a playlist and to play it.
The play method simply steps through the array of sounds you have built. It's
its own listener for the SOUND_COMPLETE event, and keeps playing until it
reaches the end of the playlist.
That approach works for all but a few songs, where it's just not precise
enough. For example, there's a pretty hyper guitar solo from "American Idiot",
with fast 16th notes (tempo about 128), and I needed to drop in one sixteenth
note in the middle of a run. The delay was just long enough--maybe 1/100
second--to make it sound like a hesitation. We had to drop that song from the
game.
Cordially,
Kerry Thompson
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders