Exemplo n.º 1
0
        /// <summary>
        /// Creates a new synchronizable instance of <see cref="RecordingProvider"/> to be used with an <see cref="IRecorder"/>.
        /// </summary>
        /// <param name="Device">The Recording Device.</param>
        /// <param name="Wf"><see cref="WaveFormat"/> to use.</param>
        /// <param name="FrameRate">The <see cref="IRecorder"/>'s FrameRate.</param>
        public RecordingProvider(RecordingDevice Device, WaveFormat Wf, int FrameRate)
        {
            WaveFormat = Wf;

            BASS.RecordInit(Device.DeviceIndex);

            BASS.CurrentRecordingDevice = Device.DeviceIndex;

            var flags = BassFlags.RecordPause;

            if (Wf.Encoding == WaveFormatEncoding.Float && Wf.BitsPerSample == 32)
            {
                flags |= BassFlags.Float;
            }

            else if (Wf.Encoding == WaveFormatEncoding.Pcm && Wf.BitsPerSample == 8)
            {
                flags |= BassFlags.Byte;
            }

            else if (!(Wf.Encoding == WaveFormatEncoding.Pcm && Wf.BitsPerSample == 16))
            {
                throw new ArgumentException(nameof(Wf));
            }

            IsSynchronizable = FrameRate != -1;

            if (IsSynchronizable)
            {
                BASS.RecordingBufferLength = 3000 / FrameRate;
            }

            _handle = IsSynchronizable ? BASS.RecordStart(Wf.SampleRate, Wf.Channels, flags, BASS.RecordingBufferLength / 3, Procedure, IntPtr.Zero)
                                      : BASS.RecordStart(Wf.SampleRate, Wf.Channels, flags, Procedure);

            BASS.ChannelSetSync(_handle, SyncFlags.Free, 0, (H, C, D, U) => RecordingStopped?.Invoke(this, new EndEventArgs(null)));
        }
Exemplo n.º 2
0
 /// <summary>
 /// Initialize a Device for Recording
 /// </summary>
 public bool Init() => Bass.RecordInit(Index);
Exemplo n.º 3
0
 public Return <bool> Initialize()
 {
     return(Bass.RecordInit(DeviceIndex));
 }