Esempio n. 1
0
        SetMP3(string inputFile)
        {
            // Get information about inputFile,
            // use to give beConfig initial
            // values:

            LibsndfileWrapper.SF_INFO soundInfo =
                new LibsndfileWrapper.SF_INFO();

            LibsndfileWrapper libSndFile = new LibsndfileWrapper();

            libSndFile.GetSoundFileType(inputFile, ref soundInfo);
            beConfig = new LameWrapper.BE_CONFIG(soundInfo);
        }
        // Constructors hence
        // Write to stream
        public 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;
            }
        }
Esempio n. 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;
            }
        }