5 Replies Latest reply on Jun 22, 2011 7:28 AM by Peter Blazejewicz

    Microphone Error

    JosephRich1

      I´m developing a microphone recording system but I got an error:

      Error: Error #1000: The system is out of memory.
          at flash.utils::ByteArray/writeFloat()
          at sound/sampleHandler()[...sound.mxml:727]

       

      How can I resolve it? It´s the Wave maximum size exceeded?

       

      (I saw an entry in this forum but without any answer...)

        • 1. Re: Microphone Error
          JosephRich1 Level 1

          it is related with my Ram? I have 8gb. The limit it´s different between computers...

          • 2. Re: Microphone Error
            Peter Blazejewicz Level 4

            hi,

             

            the flash runtime uses different memory limits then could be imposed by hosting environment (read: browser or other native application). So if for example Flash runtime has no clear upper memory limit it could use at runtime the hosting application can have such limits (so if you are hitting e.g. 0.5Gb memory increase will be denied to runtime).

            You could help people to solve issue by testing:

            - in standalone Flash player (debugger e.g.)

            - in Air application

            - use flash.system.System.totalMemory to see what memory is used by Flash runtime itself (but it could not be exactly the same as total memory used by hosting application - e.g. by browser process)

            So basically this could not be related directly to amount of memory available on your system (modern systems can assign more memory to processes then "hardware" RAM as there are disks)

             

            btw: can you write to local file stream or is it Flash runtime application (so you cannot create File object that could store bytes read from Microphone). Is your "recording" feature limit-less in terms of length?

             

            regards,

            Peter

            • 3. Re: Microphone Error
              JosephRich1 Level 1

              To find the error I write the following while cicle:

                          public function record_clickHandler(event:MouseEvent):void
                          {
                              mic = Microphone.getMicrophone();
                              mic.setSilenceLevel(0, 4000);
                              mic.gain = 20;
                              mic.rate = 44;
                              soundBytes.length = 0;
                              mic.addEventListener(SampleDataEvent.SAMPLE_DATA, sampleHandler);
                          }

               

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

               

              And when we press stop:

              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();

               

              (I don´t add the vars here...)

               

              I will try to test soon to find out the memory, but until now I´m just using air 2.7 as debugger or released .exe. At least in 3 computers the ammount of time it´s different, the wave file should be limited to about 300Mb, It´s difficult to reduce more the quality because I need it...

              • 4. Re: Microphone Error
                Peter Blazejewicz Level 4

                Hi,

                 

                #1

                if you run profiler it will show you line graph of used memory (peak/current in timeline graph) - so you should be able to see where it crash

                #2

                you could use debugger to set computed criterium for breakpoint - e.g. to length of your recorded bytes ByteArray lenght: so you could stop when it pass some precomputed value:

                http://www.adobe.com/devnet/flex/articles/flashbuilder4_debugging_profiling/flashbuilder4_ debugging_profiling_02.html

                (or just write it to debugger output so when applicaton crash you would see length of existing byte array)

                It'd be best if you are able to repeat that runtime error with values writed down about above values and e.g. process memory value read from e.g. process monitor on your machine.

                The solution you're trying to implement is frequently used from the time raw-access to microphone data was introduced in Flash 10.

                 

                regards,

                Peter

                1 person found this helpful
                • 5. Re: Microphone Error
                  JosephRich1 Level 1

                  I will try, thanks!