5 Replies Latest reply on Jun 3, 2011 9:25 AM by Ruben R

    Audio Recording Limit

    Ruben R

      Does exist any limit to audio recording in flash? I created a simple wave recording from the mic but it stop at 30 minutes or less... I don´t have any problems of computer memory I think. Does it may be from the code? or is any limitation of size (the wave can reach Gb´s...)? I have searched into the docs but have not find any related problem

        • 1. Re: Audio Recording Limit
          UbuntuPenguin Level 4

          Are any errors being thrown ?


          • 2. Re: Audio Recording Limit
            Ruben R Level 1

            I have tried to detect but the file simply stops saving at a certain moment (It´s difficult to see when). It starts getting some megabytes but it stop and becames bytes... I´m just recording a simple wave with a flex decoder (of just a few lines) It is recording to my desktop and I have almost 500gb free in my drive

            • 3. Re: Audio Recording Limit
              Ruben R Level 1

              Sorry but, does anyone have any idea what could be from?

              • 4. Re: Audio Recording Limit
                Ruben R Level 1

                There´s my source (just the record):


                            import flash.events.MouseEvent;
                            import flash.events.ProgressEvent;
                            import flash.events.SampleDataEvent;
                            import flash.media.Microphone;
                            import flash.system.Capabilities;
                        
                            import mx.events.FlexEvent;
                           
                            [Bindable]
                            public var out:String = new String();
                           
                           
                            public var process:NativeProcess;
                           
                            public static const FILE_NAME:String = "recording.wav";
                           
                            public var soundBytes:ByteArray = new ByteArray();
                            [Bindable]
                            public var mic:Microphone;
                            public var nativeProcessStartupInfo:NativeProcessStartupInfo;
                            public var f:FileStream = new FileStream();
                            public var file:File;
                           
                           
                            public function record_clickHandler(event:MouseEvent):void
                            {
                                record.visible=false;
                                stop.visible=true;
                                initclock();
                                event.currentTarget.enabled = false;
                                stop.enabled = !event.currentTarget.enabled;
                                mic = Microphone.getMicrophone();
                                mic.setSilenceLevel(0, 4000);
                                mic.gain = 30;
                                mic.rate = 44;
                                soundBytes.length = 0;
                                mic.addEventListener(SampleDataEvent.SAMPLE_DATA, sampleHandler);
                            }

                 

                            public function sampleHandler(event:SampleDataEvent):void
                            {
                                progressbar1_progressHandler();
                                while(event.data.bytesAvailable){
                                    soundBytes.writeFloat(event.data.readFloat());
                                }
                            }

                 

                            }
                            public function stop_clickHandler(event:MouseEvent):void
                            {
                                event.currentTarget.enabled = false;
                                record.enabled = !event.currentTarget.enabled;
                                out = new String();
                                mic.removeEventListener(SampleDataEvent.SAMPLE_DATA, sampleHandler);
                                soundBytes.position = 0;
                                file = File.desktopDirectory.resolvePath(FILE_NAME);
                                f.open( file, FileMode.WRITE);
                                f.writeBytes(WaveEncoder.encode(soundBytes, 1));
                                f.close();
                            }

                 

                 

                and the encoder:

                package
                {
                    import flash.events.Event;
                    import flash.utils.ByteArray;
                    import flash.utils.Endian;
                   
                    public class WaveEncoder
                    {
                        static public function encode( samples:ByteArray, channels:int=2, bits:int=16, rate:int=44100 ):ByteArray
                        {
                            var data:ByteArray = WaveEncoder.create( samples );
                           
                            var bytes: ByteArray = new ByteArray();
                            bytes.endian = Endian.LITTLE_ENDIAN;
                           
                            bytes.writeUTFBytes( 'RIFF' );
                            bytes.writeInt( uint( data.length + 44 ) );
                            bytes.writeUTFBytes( 'WAVE' );
                            bytes.writeUTFBytes( 'fmt ' );
                            bytes.writeInt( uint( 16 ) );
                            bytes.writeShort( uint( 1 ) );
                            bytes.writeShort( channels );
                            bytes.writeInt( rate );
                            bytes.writeInt( uint( rate * channels * ( bits / 8 ) ) );
                            bytes.writeShort( uint( channels * ( bits / 8 ) ) );
                            bytes.writeShort( bits );
                            bytes.writeUTFBytes( 'data' );
                            bytes.writeInt( data.length );
                            bytes.writeBytes( data );
                            bytes.position = 0;
                            return bytes;
                        }
                       
                        static private function create( bytes:ByteArray ):ByteArray
                        {
                            var buffer:ByteArray = new ByteArray();
                            buffer.endian = Endian.LITTLE_ENDIAN;
                            bytes.position = 0;
                           
                            while( bytes.bytesAvailable )
                                buffer.writeShort( bytes.readFloat() * 0x7fff );
                            return buffer;
                        }
                    }
                }

                • 5. Re: Audio Recording Limit
                  Ruben R Level 1

                  thanks anyway, I will depart to java...