예제 #1
0
        /// <summary>
        /// Populate the media type
        /// </summary>
        /// <param name="psc">IGenericSampleConfig onto which we set the media type</param>
        override public void SetMediaType(IGenericSampleConfig psc)
        {
            AMMediaType amt = new AMMediaType();

            amt.majorType  = MediaType.Stream;
            amt.subType    = MediaSubType.Mpeg2Program;
            amt.formatType = Guid.Empty;

            int hr = psc.SetMediaTypeEx(amt, BUFSIZE);

            DsError.ThrowExceptionForHR(hr);

            DsUtils.FreeAMMediaType(amt);
        }
예제 #2
0
        /// <summary>
        /// Set the media type based on values from BASS.DLL
        /// </summary>
        /// <param name="psc">The IGenericSampleConfig onto which we set the mediatype</param>
        override public void SetMediaType(IGenericSampleConfig psc)
        {
            int lFrequency = 0;
            int lVolume    = 0;
            int lPan       = 0;

            WaveFormatEx     w     = new WaveFormatEx();
            BASS_CHANNELINFO lInfo = new BASS_CHANNELINFO();

            Bass.BASS_ChannelGetInfo(m_fChan, lInfo);
            if ((lInfo.flags & (int)BASSStream.BASS_SAMPLE_8BITS) == (int)BASSStream.BASS_SAMPLE_8BITS)
            {
                w.wBitsPerSample = 8;
            }
            else
            {
                w.wBitsPerSample = 16;
            }
            Bass.BASS_ChannelGetAttributes(m_fChan, ref lFrequency, ref lVolume, ref lPan);

            w.cbSize          = (short)Marshal.SizeOf(typeof(WaveFormatEx));
            w.nChannels       = (short)lInfo.chans;
            w.nSamplesPerSec  = lFrequency;
            w.wFormatTag      = 1;
            w.nAvgBytesPerSec = w.nSamplesPerSec * w.nBlockAlign;
            m_BytesPerSample  = (short)(w.nChannels * (w.wBitsPerSample / 8));
            m_Frequency       = lFrequency;
            m_Channels        = lInfo.chans;
            w.nBlockAlign     = (short)m_BytesPerSample;
            w.nAvgBytesPerSec = w.nSamplesPerSec * w.nBlockAlign;

            AMMediaType amt = new AMMediaType();

            amt.majorType  = MediaType.Audio;
            amt.subType    = MediaSubType.PCM;
            amt.formatType = FormatType.WaveEx;
            amt.formatPtr  = Marshal.AllocCoTaskMem(w.cbSize);
            amt.formatSize = w.cbSize;
            Marshal.StructureToPtr(w, amt.formatPtr, false);

            int hr = psc.SetMediaTypeEx(amt, BUFSIZE);

            DsError.ThrowExceptionForHR(hr);

            DsUtils.FreeAMMediaType(amt);
        }
예제 #3
0
        /// <summary>
        /// Populate the media type
        /// </summary>
        /// <param name="psc">IGenericSampleConfig onto which we set the media type</param>
        public override void SetMediaType(IGenericSampleConfig psc)
        {
            AMMediaType amt = new AMMediaType();
            amt.majorType = MediaType.Stream;
            amt.subType = MediaSubType.Mpeg2Program;
            amt.formatType = Guid.Empty;

            int hr = psc.SetMediaTypeEx(amt, BUFSIZE);
            DsError.ThrowExceptionForHR(hr);

            DsUtils.FreeAMMediaType(amt);
        }
예제 #4
0
        /// <summary>
        /// Set the media type based on values from BASS.DLL
        /// </summary>
        /// <param name="psc">The IGenericSampleConfig onto which we set the mediatype</param>
        public override void SetMediaType(IGenericSampleConfig psc)
        {
            int lFrequency = 0;
            int lVolume = 0;
            int lPan = 0;

            WaveFormatEx w = new WaveFormatEx();
            BASS_CHANNELINFO lInfo = new BASS_CHANNELINFO();

            Bass.BASS_ChannelGetInfo(m_fChan, lInfo);
            if ((lInfo.flags & (int)BASSStream.BASS_SAMPLE_8BITS) == (int)BASSStream.BASS_SAMPLE_8BITS)
            {
                w.wBitsPerSample = 8;
            }
            else
            {
                w.wBitsPerSample = 16;
            }
            Bass.BASS_ChannelGetAttributes(m_fChan, ref lFrequency, ref lVolume, ref lPan);

            w.cbSize = (short)Marshal.SizeOf(typeof(WaveFormatEx));
            w.nChannels = (short)lInfo.chans;
            w.nSamplesPerSec = lFrequency;
            w.wFormatTag = 1;
            w.nAvgBytesPerSec = w.nSamplesPerSec * w.nBlockAlign;
            m_BytesPerSample = (short)(w.nChannels * (w.wBitsPerSample / 8));
            m_Frequency = lFrequency;
            m_Channels = lInfo.chans;
            w.nBlockAlign = (short)m_BytesPerSample;
            w.nAvgBytesPerSec = w.nSamplesPerSec * w.nBlockAlign;

            AMMediaType amt = new AMMediaType();
            amt.majorType = MediaType.Audio;
            amt.subType = MediaSubType.PCM;
            amt.formatType = FormatType.WaveEx;
            amt.formatPtr = Marshal.AllocCoTaskMem(w.cbSize);
            amt.formatSize = w.cbSize;
            Marshal.StructureToPtr(w, amt.formatPtr, false);

            int hr = psc.SetMediaTypeEx(amt, BUFSIZE);
            DsError.ThrowExceptionForHR(hr);

            DsUtils.FreeAMMediaType(amt);
        }