Ejemplo n.º 1
0
        int GetSampleRate()
        {
            LibmadWrapper Libmad = new LibmadWrapper();

            if (RhythmStream != null)
            {
                long currentPosition = RhythmStream.Position;
                Mp3bytes = new byte[RhythmStream.Length];
                RhythmStream.Position = 0;
                RhythmStream.Read(Mp3bytes, 0, Mp3bytes.Length);
                RhythmStream.Position = currentPosition;
            }

            IBuffer buffer = WindowsRuntimeBufferExtensions.AsBuffer(Mp3bytes, 0, Mp3bytes.Length);

            if (Libmad.DecodeMp32Pcm_Init(buffer))
            {
                int result = Libmad.ReadSamplesForSampleRate();
                Libmad.CloseFile();
                return(result);
            }
            else
            {
                return(-1);
            }
        }
Ejemplo n.º 2
0
        private void decode(object sender, RoutedEventArgs e)
        {
            IsolatedStorageFile isf    = IsolatedStorageFile.GetUserStoreForApplication();
            LibmadWrapper       Libmad = new LibmadWrapper();

            IBuffer buffer = WindowsRuntimeBufferExtensions.AsBuffer(Mp3bytes, 0, Mp3bytes.Length);

            PCMStream = isf.CreateFile("decoded_pcm.pcm");

            bool init = Libmad.DecodeMp32Pcm_Init(buffer);

            if (init)
            {
                List <short>  samples = new List <short>();
                RawPCMContent rpcc    = null;
                try
                {
                    while ((rpcc = Libmad.ReadSample()).count != 0)
                    {
                        short[] shortBytes = rpcc.PCMData.ToArray <short>();
                        byte[]  rawbytes   = new byte[shortBytes.Length * 2];
                        for (int i = 0; i < shortBytes.Length; i++)
                        {
                            rawbytes[2 * i]     = (byte)shortBytes[i];
                            rawbytes[2 * i + 1] = (byte)(shortBytes[i] >> 8);
                        }
                        PCMStream.Write(rawbytes, 0, rawbytes.Length);
                    }
                    PCMStream.Flush();
                    PCMStream.Close();
                    PCMStream.Dispose();
                    MessageBox.Show("over");
                    Libmad.CloseFile();
                }
                catch (Exception exception)
                {
                    MessageBox.Show(exception.Message);
                }
            }
            isf.Dispose();
        }
Ejemplo n.º 3
0
 private void decode(object sender, RoutedEventArgs e)
 {
     IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication();
     LibmadWrapper Libmad = new LibmadWrapper();
     
     IBuffer buffer = WindowsRuntimeBufferExtensions.AsBuffer(Mp3bytes, 0, Mp3bytes.Length);
     PCMStream = isf.CreateFile("decoded_pcm.pcm");
    
     bool init = Libmad.DecodeMp32Pcm_Init(buffer);
     if (init)
     {
         List<short> samples = new List<short>();
         RawPCMContent rpcc = null;
         try
         {
             while ((rpcc = Libmad.ReadSample()).count != 0)
             {
                 short[] shortBytes = rpcc.PCMData.ToArray<short>();
                 byte[] rawbytes = new byte[shortBytes.Length * 2];
                 for (int i = 0; i < shortBytes.Length; i++)
                 {
                     rawbytes[2 * i] = (byte)shortBytes[i];
                     rawbytes[2 * i + 1] = (byte)(shortBytes[i] >> 8);
                 }
                  PCMStream.Write(rawbytes, 0, rawbytes.Length);
             }
             PCMStream.Flush();
             PCMStream.Close();
             PCMStream.Dispose();
             MessageBox.Show("over");
             Libmad.CloseFile();    
         }
         catch (Exception exception)
         {
             MessageBox.Show(exception.Message);
         }
     }
     isf.Dispose();
 }
Ejemplo n.º 4
0
     int GetSampleRate()
     {
         LibmadWrapper Libmad = new LibmadWrapper();
    
             if (RhythmStream != null)
             {
                 long currentPosition = RhythmStream.Position;
                 Mp3bytes = new byte[RhythmStream.Length];
                 RhythmStream.Position = 0;
                 RhythmStream.Read(Mp3bytes, 0, Mp3bytes.Length);
                 RhythmStream.Position = currentPosition;
             }
 
         IBuffer buffer = WindowsRuntimeBufferExtensions.AsBuffer(Mp3bytes, 0, Mp3bytes.Length);
         if (Libmad.DecodeMp32Pcm_Init(buffer))
         {
             int result = Libmad.ReadSamplesForSampleRate();
             Libmad.CloseFile();
             return result;
         }
         else
         {
             return -1;
         }
     }