示例#1
0
        private void EnsureInitialized()
        {
            if (!this.m_initialized)
            {
                m_handle = libmp3lamedll.lame_init();

                libmp3lamedll.lame_set_bWriteVbrTag(m_handle, 1);
                libmp3lamedll.lame_set_write_id3tag_automatic(m_handle, 0);

                libmp3lamedll.lame_set_num_channels(m_handle, this.Settings.PCM.ChannelCount);
                libmp3lamedll.lame_set_in_samplerate(m_handle, this.Settings.PCM.SampleRate);

                if (this.m_finalSampleCount != 0)
                {
                    libmp3lamedll.lame_set_num_samples(m_handle, this.m_finalSampleCount);
                }

                m_settings.Apply(m_handle);

                if (libmp3lamedll.lame_init_params(m_handle) != 0)
                {
                    throw new LameException("lame_init_params failed");
                }

                this.m_initialized = true;
            }
        }
示例#2
0
        private void EnsureInitialized()
        {
            if (!this.m_initialized)
            {
                m_handle = libmp3lamedll.lame_init();

                libmp3lamedll.lame_set_bWriteVbrTag(m_handle, 1);
                libmp3lamedll.lame_set_write_id3tag_automatic(m_handle, 0);

                libmp3lamedll.lame_set_num_channels(m_handle, this.Settings.PCM.ChannelCount);
                libmp3lamedll.lame_set_in_samplerate(m_handle, this.Settings.PCM.SampleRate);

                if (this.m_finalSampleCount != 0)
                {
                    libmp3lamedll.lame_set_num_samples(m_handle, this.m_finalSampleCount);
                }

                m_settings.Apply(m_handle);

                if (libmp3lamedll.lame_init_params(m_handle) != 0)
                {
                    throw new LameException("lame_init_params failed");
                }

                byte[] id3v2   = { 0x49, 0x44, 0x33, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
                int    padding = m_settings.Padding;
                int    id3v2sz = padding;
                int    i       = 9;
                do
                {
                    id3v2[i--] = (byte)(id3v2sz & 0x7f);
                    id3v2sz  >>= 7;
                } while (id3v2sz != 0);
                m_outputStream.Write(id3v2, 0, id3v2.Length);
                m_bytesWritten += id3v2.Length;
                m_outputStream.Write(new byte[padding], 0, padding);
                m_bytesWritten += padding;
                m_streamStart   = this.m_outputStream.Position;

                this.m_initialized = true;
            }
        }