Re: [Flashcoders] Is a precise timer for making rhythms possible?
Eric E. Dolecki wrote: I think he means a prior composition No. I mean the one just generated. Ron Sent from my iPod On Jul 12, 2008, at 3:55 PM, Kerry Thompson [EMAIL PROTECTED] wrote: Ron Wheeler wrote: If you have a playback button that plays the composed work, you can concatenate the sounds/notes selected and play the composed segment. That's interesting--can that be done at runtime? How can you concatenate the sounds? 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
Re: [Flashcoders] Is a precise timer for making rhythms possible?
I would do it on the server side. Since you are using a stable set of notes, you could have a duplicate set on the server and have the Flash Player send the list that you want assembled and the server could return an MP3. You could also have the server save the sequence for later examination or replay. Looking more like MIDI by the day. Put a MIDI player on the server. There are probably ways to do it on the client as well. Ron Kerry Thompson wrote: Ron Wheeler wrote: If you have a playback button that plays the composed work, you can concatenate the sounds/notes selected and play the composed segment. That's interesting--can that be done at runtime? How can you concatenate the sounds? 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
Re: [Flashcoders] Is a precise timer for making rhythms possible?
In my case there is a strong interactive part, and there is not enough time to send user interaction data to the server and then render the sound. And we have thousands of simultaneous users, so it's too much load for any cpu. Anyways I know there is client side sound generation, like the found in http://code.google.com/p/popforge/ or http://8bitboy.popforge.de/ or all examples from Andre Michelle. Maybe I try that in the future. Then the sound will probably have no glitches. I wonder about how well would be graphics synchronized to the sound though... Ron Wheeler wrote: I would do it on the server side. Since you are using a stable set of notes, you could have a duplicate set on the server and have the Flash Player send the list that you want assembled and the server could return an MP3. You could also have the server save the sequence for later examination or replay. Looking more like MIDI by the day. Put a MIDI player on the server. There are probably ways to do it on the client as well. Ron Kerry Thompson wrote: Ron Wheeler wrote: If you have a playback button that plays the composed work, you can concatenate the sounds/notes selected and play the composed segment. That's interesting--can that be done at runtime? How can you concatenate the sounds? Cordially, Kerry Thompson ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Is a precise timer for making rhythms possible?
Abe Pazos wrote: In my case there is a strong interactive part, and there is not enough time to send user interaction data to the server and then render the sound. And we have thousands of simultaneous users, so it's too much load for any cpu. It should not take long to render and thousands of users simultaneously wanting to compose a song sounds like a rather interesting application with a huge market and lots of ways to get funds. I doubt if it will get bigger than Google or MSN so I would not worry about the server side stuff very much. If you actually do get to 1000 simultaneous users (implies several tens of thousands of clients) you will likely store the MP3 notes in memory and build the composition right into the HTTP server's response stream on a number of load balanced parallel servers. Anyways I know there is client side sound generation, like the found in http://code.google.com/p/popforge/ or http://8bitboy.popforge.de/ or all examples from Andre Michelle. Looks interesting and from the short description, pretty much what you are looking for. Maybe I try that in the future. Then the sound will probably have no glitches. I wonder about how well would be graphics synchronized to the sound though... If you are playing a sound file, the trick is to synchronize the graphics to the sound. Watch the sound file progress and orchestrate the graphics to match the sound's progress. We do this all the time in our eLearning delivery application that synchronizes on-screen actions with the narration. If something graphical is supposed to happen at 10.25 seconds into the sound file, then trigger it at that time. If you are doing timeline graphics then you need to watch the timeline and keep it in synch. It is less obvious to the user if you miss the timing on a visual event than if you screw up the playing of music. That is why I originally suggested the construction of a single sound file rather than trying to deliver a note on schedule. Ron Ron Wheeler wrote: I would do it on the server side. Since you are using a stable set of notes, you could have a duplicate set on the server and have the Flash Player send the list that you want assembled and the server could return an MP3. You could also have the server save the sequence for later examination or replay. Looking more like MIDI by the day. Put a MIDI player on the server. There are probably ways to do it on the client as well. Ron Kerry Thompson wrote: Ron Wheeler wrote: If you have a playback button that plays the composed work, you can concatenate the sounds/notes selected and play the composed segment. That's interesting--can that be done at runtime? How can you concatenate the sounds? 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
RE: [Flashcoders] Is a precise timer for making rhythms possible?
Ron Wheeler wrote: It is less obvious to the user if you miss the timing on a visual event than if you screw up the playing of music. You're probably right on that most of the time--that's why video will choose to drop a frame to keep in synch. It's also why voice-over for foreign-language films works. I think Abe's application is an exception. From what I understand, he doesn't need millisecond-accurate timing, but his audio does need to be in synch with the visual events. In my case, I don't need timing so much as the ability to play sounds in sequence with no perceptible pause--even a few milliseconds to start an MP3 spoils the effect I need. That's why I was interested in your idea of concatenation. That is why I originally suggested the construction of a single sound file rather than trying to deliver a note on schedule. Makes sense--the timer in Flash is undependable, as Abe has noted. It can be off by several milliseconds. I.e., you can set a timer to fire every 45 ms, and it often fires late--up to 10 ms late, I've found. It's easy to understand why. If you have several programs running, or have a download or upload running in the background, Flash simply may not have the CPU's attention when it needs to fire. Your solution of concatenating on the server is cool. For my application, like Abe's, I have to have real-time playback, though, and can't wait for the server to respond. Sigh. Cordially, Kerry Thompson ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Is a precise timer for making rhythms possible?
Kerry Thompson wrote: Ron Wheeler wrote: It is less obvious to the user if you miss the timing on a visual event than if you screw up the playing of music. You're probably right on that most of the time--that's why video will choose to drop a frame to keep in synch. It's also why voice-over for foreign-language films works. I think Abe's application is an exception. From what I understand, he doesn't need millisecond-accurate timing, but his audio does need to be in synch with the visual events. In my case, I don't need timing so much as the ability to play sounds in sequence with no perceptible pause--even a few milliseconds to start an MP3 spoils the effect I need. That's why I was interested in your idea of concatenation. That is why I originally suggested the construction of a single sound file rather than trying to deliver a note on schedule. Makes sense--the timer in Flash is undependable, as Abe has noted. It can be off by several milliseconds. I.e., you can set a timer to fire every 45 ms, and it often fires late--up to 10 ms late, I've found. It's easy to understand why. If you have several programs running, or have a download or upload running in the background, Flash simply may not have the CPU's attention when it needs to fire. Your solution of concatenating on the server is cool. For my application, like Abe's, I have to have real-time playback, though, and can't wait for the server to respond. Sigh. The in-memory concatenation looks good if it can be done in AS2 as well as AS3. I wonder if HaXe might be a better solution. It might give a better outcome with less code and code that is more maintainable. 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
RE: [Flashcoders] Is a precise timer for making rhythms possible?
Ron Wheeler wrote: The in-memory concatenation looks good if it can be done in AS2 as well as AS3. I agree. Do you know of a way of doing it? I have a Playlist class that plays the sounds you choose, one after another, but I don't know of a way of concatenating them like you would a string. I wonder if HaXe might be a better solution. It might give a better outcome with less code and code that is more maintainable. I'll look into that--I've heard many good things about it. This is a Flex project, though, with .swf assets, and it's already in beta--too late to change now. Cordially, Kerry Thompson ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Is a precise timer for making rhythms possible?
Kerry Thompson wrote: Ron Wheeler wrote: The in-memory concatenation looks good if it can be done in AS2 as well as AS3. I agree. Do you know of a way of doing it? I have a Playlist class that plays the sounds you choose, one after another, but I don't know of a way of concatenating them like you would a string. The Sound object discussed in http://code.google.com/p/popforge/ looked promising. I wonder if HaXe might be a better solution. It might give a better outcome with less code and code that is more maintainable. I'll look into that--I've heard many good things about it. This is a Flex project, though, with .swf assets, and it's already in beta--too late to change now. We just took our AS2 core code and swf's and tied it together with Haxe to make a Flash RIA and it worked fine. We will migrate the last of the AS2 to Haxe as we re-engineer the package. 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
RE: [Flashcoders] Is a precise timer for making rhythms possible?
Ron Wheeler wrote: The Sound object discussed in http://code.google.com/p/popforge/ looked promising. Thanks, Ron. They do talk about an AudioBuffer class that sounds interesting. I've downloaded it, and I'll take a look at it. I'll owe you and them a big thanks if it has some eye-opening code ^_^ The Sound object is what I'm using--to play a sound in AS3, you create a Sound object from your asset and assign it to a SoundChannel, which is what you play. Counter-intuitive, I know, but you play the channel, not the sound. Cordially, Kerry Thompson ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Is a precise timer for making rhythms possible?
If the composer is playing as notes are entered, timing is not an issue. Fancy electric organ for the typest :-) If you have a playback button that plays the composed work, you can concatenate the sounds/notes selected and play the composed segment. Ron Abe Pazos wrote: I guess this is meant for Kerry? I think he IS playing songs in a sequence. Maybe he needs to synchronize graphic elements to the starting of parts? In my case, I've built a composer tool and the order is not predefined, actually is ever changing, so I can't merge the sounds. 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 ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com
Re: [Flashcoders] Is a precise timer for making rhythms possible?
This approach has the potential to be extended to merge 2 or more generated tracks (instruments) with some consideration of volume balance between the tracks. One would concatenate the notes in each track, merge and balance the mp3s and play back the composite mp3 song. Ron Ron Wheeler wrote: If the composer is playing as notes are entered, timing is not an issue. Fancy electric organ for the typest :-) If you have a playback button that plays the composed work, you can concatenate the sounds/notes selected and play the composed segment. Ron Abe Pazos wrote: I guess this is meant for Kerry? I think he IS playing songs in a sequence. Maybe he needs to synchronize graphic elements to the starting of parts? In my case, I've built a composer tool and the order is not predefined, actually is ever changing, so I can't merge the sounds. 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 ___
RE: [Flashcoders] Is a precise timer for making rhythms possible?
Ron Wheeler wrote: If you have a playback button that plays the composed work, you can concatenate the sounds/notes selected and play the composed segment. That's interesting--can that be done at runtime? How can you concatenate the sounds? Cordially, Kerry Thompson ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Is a precise timer for making rhythms possible?
I think he means a prior composition Sent from my iPod On Jul 12, 2008, at 3:55 PM, Kerry Thompson [EMAIL PROTECTED] wrote: Ron Wheeler wrote: If you have a playback button that plays the composed work, you can concatenate the sounds/notes selected and play the composed segment. That's interesting--can that be done at runtime? How can you concatenate the sounds? 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
Re: [Flashcoders] Is a precise timer for making rhythms possible?
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
Re: [Flashcoders] Is a precise timer for making rhythms possible?
Isn't MIDI designed for this type of application http://www.alexisisaac.net/products/flashMidi/ 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
Re[2]: [Flashcoders] Is a precise timer for making rhythms possible?
Following this discussion I wondered if you are aware of this: http://www.b-nm.at/flash-sound-synchronisation/ (also as normal webpage, but then the ascii examples wont work: http://www.actionscript.org/resources/articles/159/1/Advanced-Flash-MX-Sound-Timing/Page1.html ) Could explain the seemingly irregular mp3 play times. The bad news is: this technique relies on the precision of the Sound_Complete Event wich has become more and more unreliable with every new PlayerRevision since FP8 (and it will even be worse in FP10...) If this is old stuff - sorry for the noise. I will definitely give playback of the WAV/AIFF instead of mp3 a try, thanks for that! -- Aloha, tom ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Is a precise timer for making rhythms possible?
Sure, too bad Flash doesn't include Midi and precise timing. FlashMidi only works in windows, it must be installed and uses non standard tricks to install. It's cool for custom art projects, but not for the general public on a web site, as required in my project (must run on standard Flash Player on any platform). Thanks for the link though, I will try it for my own experiments. Isn't MIDI designed for this type of application http://www.alexisisaac.net/products/flashMidi/ 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 ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Is a precise timer for making rhythms possible?
I guess this is meant for Kerry? I think he IS playing songs in a sequence. Maybe he needs to synchronize graphic elements to the starting of parts? In my case, I've built a composer tool and the order is not predefined, actually is ever changing, so I can't merge the sounds. 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 ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
RE: Re[2]: [Flashcoders] Is a precise timer for making rhythms possible?
Thanks for the link Tom. Yes, that's the method I was following, and since it didn't work I wrote to this list to ask for ideas :) The page mentions a stable 46 ms clock, but as I have tested it, it's not stable at all. I guess it's what you mention about SOUND_COMPLETE becoming less reliable. I tested exporting RAW instead of MP3 and I can not see a clearly more precise timing. Maybe slightly better, but I don't get a fixed 46 ms timer. I would say 4 out of 5 times it's 45/46/47 ms, and 1 out of 5 it's something totally different, like 23 ms or 70 ms or even 100 ms. And if they say it will get worse in FP10... that's bad news. They will make it possible to generate real time sound, but the timers will get less precise? or only the SOUND_COMPLETE event? In the worst case I can 'synthesise' (render) the track in real time, in that case I will get perfect timing I guess... (and more CPU usage). My application is anyways working, I'm just looking for tighter timing, and if it's not possible, then it's not. Following this discussion I wondered if you are aware of this: http://www.b-nm.at/flash-sound-synchronisation/ (also as normal webpage, but then the ascii examples wont work: http://www.actionscript.org/resources/articles/159/1/Advanced-Flash-MX-Sound-Ti ming/Page1.html ) Could explain the seemingly irregular mp3 play times. The bad news is: this technique relies on the precision of the Sound_Complete Event wich has become more and more unreliable with every new PlayerRevision since FP8 (and it will even be worse in FP10...) If this is old stuff - sorry for the noise. I will definitely give playback of the WAV/AIFF instead of mp3 a try, thanks for that! -- Aloha, tom ___ 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
RE: [Flashcoders] Is a precise timer for making rhythms possible?
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
RE: [Flashcoders] Is a precise timer for making rhythms possible?
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? Not necessarily. In CS3, Publish Settings, the Flash tab, Audio Stream and Audio Event both have a set button. You can control the bitrate of an mp3, or you can set it to raw, which will leave the file as aiff. You can even disable compression, which, I think, allows you to use even higher-quality audio than 44/16. I'm using raw, and it starts playing significantly faster than mp3--even a trimmed mp3. 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? I can't tell you what goes on under the hood, but yes, there is more of a delay starting an MP3 than an unprocessed aiff. 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... It's not so much on-the-millisecond precision--that doesn't work, as your code shows. There are vagaries in when a timer fires, and there are delays on playing MP3s (the MP3s are all downloaded before I play them). You may be looking for something different than I am. I'm assembling a song like a jigsaw puzzle, and it has to sound right, regardless of the speed. As soon as one phrase stops, the next phrase, or note, must begin without hesitation, even if it's a single note in an up-tempo song. I've gotten close with 44/16 aiff files, but there are some songs that are still too fast to drop a single note in the middle of a fast passage. Cordially, Kerry Thompson ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
[Flashcoders] Is a precise timer for making rhythms possible?
Hi! this has been probably asked before, but since I don't know how to search the lists (is it possible at all?): I have built a Flash application in AS3 for making algorithmic music. It's currently acceptable for any music except rhythms, because the timers are not precise enough. I have tried: * onEnterFrame * normal Timer * Very short timer (5ms) in combination with getTimer(). That's my current method, and it's not impressive, but works ok. * 1 sample sound with onSoundComplete, to get a stable 46 ms timer. Doesn't seem to work any better than the others. I have done many tests, traces, and graphs about time deviation. I have the impression that the method I use now has very few milliseconds of error, but maybe the sounds are not started immediately when I tell them to play. Are they maybe aligned to the next frame? Is there any known method for a more precise triggering of samples? I don't need a constant stream of audio, since I'm not synthesizing on real time. I just want a metronome with higher precision. Any ideas? Is this concept about the 100 empty milliseconds at the beginning of the sounds, and using delays still valid today? I haven't tried that one. I also read 8 simultaneous sounds is the limit. Is that so? What happens when you use more? Thanks! =) ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
RE: [Flashcoders] Is a precise timer for making rhythms possible?
Check the Flash_Tiger list archives on Yahoo - we just had a huge discussion about this kind of thing with a question Kerry Thompson asked - about 1-2 weeks ago. Or ask there, Kerry Thompson (who may also be listening here) gathered a lot of info about this development problem. Jason Merrill Bank of America Global Technology Operations Global Risk LLD eTools Multimedia Join the Bank of America Flash Platform Developer Community Are you a Bank of America associate interested in innovative learning ideas and technologies? Check out our internal GTO Innovative Learning Blog subscribe. ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
RE: [Flashcoders] Is a precise timer for making rhythms possible?
Hi! this has been probably asked before, but since I don't know how to search the lists (is it possible at all?): It's possible, but the Flashcoders archives got zapped when they had hardware problems last year. We also have archives on Flash_Tiger, as Jason mentioned. I have built a Flash application in AS3 for making algorithmic music. It's currently acceptable for any music except rhythms, because the timers are not precise enough. I have tried: * onEnterFrame * normal Timer * Very short timer (5ms) in combination with getTimer(). That's my current method, and it's not impressive, but works ok. * 1 sample sound with onSoundComplete, to get a stable 46 ms timer. Doesn't seem to work any better than the others. 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