// Conversion routine overload // (madlldlib) // // Convert() routine overload for // MP3 decoding using madlldlib. // Expects 'inputFile' to be MP3. // // Note: Calling this method in // your code requires you to // release your code under GPL // terms. See the readme.txt // file in this distribution // for details. public void Convert(string inputFile, string outputFile, soundFormat convertTo, MadlldlibWrapper.Callback updateStatus) { // Handle incorrect output types if ( !(convertTo == soundFormat.WAV) && !(convertTo == soundFormat.RAW) ) { throw new Exception( "Cannot convert from MP3 to this format directly: " + convertTo); } // Check that file is MP3 // Search through .5 of file // before quitting MP3Check verifyMP3 = new MP3Check(inputFile, 2); if (!verifyMP3.Check()) { throw new Exception("Not a valid MP3 file: " + inputFile); } // Convert to short pathnames inputFilePath.Capacity = MAX_STRLEN; outputFilePath.Capacity = MAX_STRLEN; GetShortPathName(inputFile, inputFilePath, MAX_STRLEN); GetShortPathName(outputFile, outputFilePath, MAX_STRLEN); // Assign if returned path is not zero: if (inputFilePath.Length > 0) inputFile = inputFilePath.ToString(); if (outputFilePath.Length > 0) outputFile = outputFilePath.ToString(); // status/error message reporting. // String length must be set // explicitly StringBuilder status = new StringBuilder(); status.Capacity=256; // call the decoding function if (convertTo == soundFormat.WAV) { MadlldlibWrapper.DecodeMP3(inputFile, outputFile, MadlldlibWrapper.DEC_WAV, status, updateStatus); } else // Convert to PCM (raw): { MadlldlibWrapper.DecodeMP3(inputFile, outputFile, MadlldlibWrapper.DEC_PCM, status, updateStatus); } // this prevents garbage collection // from occurring on callback GC.KeepAlive(updateStatus); }
private bool ReportStatusMad(uint frameCount, uint byteCount, ref MadlldlibWrapper.mad_header mh) { SetControlPropertyValue(progressBar1, "value", (int)(((float)byteCount / (float)soundFileSize) * 100)); return true; }