コード例 #1
0
        Close()
        {
            uint err = 0;


            // De-init stream

            err = LameWrapper.beDeinitStream(hLameStream, mp3Buffer, ref dwOut);

            if (err != LameWrapper.BE_ERR_SUCCESSFUL)
            {
                throw new ApplicationException("beDeinitStream failed");
            }


            // Write any bytes returned from deinit

            if (dwOut > 0)
            {
                base.Write(mp3Buffer, 0, (int)dwOut);
            }


            // Close stream

            LameWrapper.beCloseStream(hLameStream);
            base.Close();
        }
コード例 #2
0
        WriteTags(string outputFile)
        {
            // Write INFO/VBR

            uint err = LameWrapper.beWriteInfoTag(hLameStream, outputFile);

            if (err != LameWrapper.BE_ERR_SUCCESSFUL)
            {
                throw new ApplicationException("WriteInfoTag failed");
            }
        }
コード例 #3
0
        LameWriter(Stream outputStream, string inputFile) :
            base(outputStream)
        {
            // GetSoundFileType input file

            int rtn = libSndFile.GetSoundFileType(inputFile, ref soundInfo);


            // Initialize

            beConfig = new LameWrapper.BE_CONFIG(soundInfo);
            try
            {
                uint rslt =
                    LameWrapper.beInitStream(beConfig,
                                             ref samples, ref bufferSize, ref hLameStream);

                if (rslt != LameWrapper.BE_ERR_SUCCESSFUL)
                {
                    throw new ApplicationException(
                              string.Format(
                                  "LameWrapper.beInitStream failed with code: {0}",
                                  rslt));
                }

                // Samples are 2 bytes wide:

                sampleSize = (int)samples * 2;

                // MP3 buffer

                mp3Buffer = new byte[bufferSize];
            }
            catch
            {
                throw;
            }
        }
コード例 #4
0
        Write(byte[] buffer, int index, int count)
        {
            // Encode samples

            uint err = LameWrapper.EncodeChunk(
                hLameStream, buffer, mp3Buffer, ref dwOut);

            if (err != LameWrapper.BE_ERR_SUCCESSFUL)
            {
                throw new ApplicationException(
                          string.Format(
                              "LameWrapper.EncodeChunk failed with code: {0}",
                              err));
            }


            // Write to the file

            if (dwOut > 0)
            {
                base.Write(mp3Buffer, 0, (int)dwOut);
            }
        }
コード例 #5
0
        // Overload constructor: Send
        // custom BE_CONFIG
        public LameWriter(Stream outputStream, 
            string inputFile, LameWrapper.BE_CONFIG beConfig)
            : base(outputStream)
        {
            // GetSoundFileType input file
            int rtn = libSndFile.GetSoundFileType(inputFile, ref soundInfo);

            // Initialize

            try
            {

                uint rslt = LameWrapper.beInitStream(beConfig,
                        ref samples, ref bufferSize, ref hLameStream);

                if (rslt != LameWrapper.BE_ERR_SUCCESSFUL)
                {
                    throw new ApplicationException(
                            string.Format(
                                "LameWrapper.beInitStream failed with code: {0}",
                               	rslt));
                }

                // Samples are 2 bytes wide:

                sampleSize = (int)samples*2;

                // MP3 buffer:

                mp3Buffer = new byte[bufferSize];

            }
            catch
            {
                throw;
            }
        }