/// <summary>
        ///  サンプルフォーマットタイプ→有効ビット数(1サンプル1chあたり。バイト数ではなくビット数)
        /// </summary>
        /// <param name="t">サンプルフォーマットタイプ</param>
        /// <returns>有効ビット数(1サンプル1chあたり。バイト数ではなくビット数)</returns>
        public static int SampleFormatTypeToValidBitsPerSample(SampleFormatType t)
        {
            switch (t)
            {
            case SampleFormatType.Sint16:
                return(16);

            case SampleFormatType.Sint24:
                return(24);

            case SampleFormatType.Sint32V24:
                return(24);

            case SampleFormatType.Sint32:
                return(32);

            case SampleFormatType.Sfloat:
                return(32);

            case SampleFormatType.Sdouble:
                return(64);

            default:
                System.Diagnostics.Debug.Assert(false);
                return(0);
            }
        }
Exemple #2
0
 public MixFormat(int sampleRate, SampleFormatType sampleFormat, int numChannels, int dwChannelMask)
 {
     this.sampleRate    = sampleRate;
     this.sampleFormat  = sampleFormat;
     this.numChannels   = numChannels;
     this.dwChannelMask = dwChannelMask;
 }
Exemple #3
0
        public int Setup(int deviceId, DeviceType t, StreamType streamType,
                         int sampleRate, SampleFormatType format, int numChannels,
                         int dwChannelMask,
                         MMCSSCallType mmcssCall, MMThreadPriorityType threadPriority,
                         SchedulerTaskType schedulerTask, ShareMode shareMode, DataFeedMode dataFeedMode,
                         int latencyMillisec, int zeroFlushMillisec, int timePeriodHandredNanosec,
                         bool isFormatSupportedCall)
        {
            var args = new SetupArgs();

            args.deviceType               = (int)t;
            args.streamType               = (int)streamType;
            args.sampleRate               = sampleRate;
            args.sampleFormat             = (int)format;
            args.numChannels              = numChannels;
            args.dwChannelMask            = dwChannelMask;
            args.mmcssCall                = (int)mmcssCall;
            args.mmThreadPriority         = (int)threadPriority;
            args.schedulerTask            = (int)schedulerTask;
            args.shareMode                = (int)shareMode;
            args.dataFeedMode             = (int)dataFeedMode;
            args.latencyMillisec          = latencyMillisec;
            args.timePeriodHandledNanosec = timePeriodHandredNanosec;
            args.zeroFlushMillisec        = zeroFlushMillisec;
            args.isFormatSupportedCall    = isFormatSupportedCall ? 1 : 0;
            return(WasapiIO_Setup(mId, deviceId, ref args));
        }
Exemple #4
0
 public BufferFormat(uint channelCount, uint samplesPerSecond, uint bitsPerSample, SampleFormatType sampleFormat = SampleFormatType.Float)
 {
     this.ChannelCount       = channelCount;
     this.SamplesPerSecond   = samplesPerSecond;
     this.BitsPerSample      = bitsPerSample;
     this.ValidBitsPerSample = bitsPerSample;
     this.SampleFormat       = sampleFormat;
 }
Exemple #5
0
 internal BufferFormat(NativeBindings.MLAudioBufferFormat bufferFormatNative)
 {
     this.ChannelCount       = bufferFormatNative.ChannelCount;
     this.SamplesPerSecond   = bufferFormatNative.SamplesPerSecond;
     this.BitsPerSample      = bufferFormatNative.BitsPerSample;
     this.ValidBitsPerSample = bufferFormatNative.ValidBitsPerSample;
     this.SampleFormat       = bufferFormatNative.SampleFormat;
 }
        public int InspectDevice(int deviceId, int sampleRate, SampleFormatType format, int numChannels)
        {
            var args = new InspectArgs();

            args.sampleRate   = sampleRate;
            args.numChannels  = numChannels;
            args.sampleFormat = (int)format;
            return(WasapiIO_InspectDevice(mId, deviceId, ref args));
        }
Exemple #7
0
        public int InspectDevice(int deviceId, DeviceType dt, int sampleRate, SampleFormatType format, int numChannels, int dwChannelMask)
        {
            var args = new InspectArgs();

            args.deviceType    = (int)dt;
            args.sampleRate    = sampleRate;
            args.numChannels   = numChannels;
            args.sampleFormat  = (int)format;
            args.dwChannelMask = dwChannelMask;
            return(WasapiIO_InspectDevice(mId, deviceId, ref args));
        }
 public SessionStatus(StreamType streamType, int pcmDataSampleRate, int deviceSampleRate, SampleFormatType deviceSampleFormat,
                      int deviceBytesPerFrame, int deviceNumChannels, int timePeriodHandledNanosec, int bufferFrameNum)
 {
     StreamType               = streamType;
     PcmDataSampleRate        = pcmDataSampleRate;
     DeviceSampleRate         = deviceSampleRate;
     DeviceSampleFormat       = deviceSampleFormat;
     DeviceBytesPerFrame      = deviceBytesPerFrame;
     DeviceNumChannels        = deviceNumChannels;
     TimePeriodHandledNanosec = timePeriodHandledNanosec;
     EndpointBufferFrameNum   = bufferFrameNum;
 }
        public static BitFormatType SampleFormatTypeToBitFormatType(SampleFormatType t)
        {
            switch (t)
            {
            case SampleFormatType.Sint16:
            case SampleFormatType.Sint24:
            case SampleFormatType.Sint32V24:
            case SampleFormatType.Sint32:
                return(BitFormatType.SInt);

            case WasapiCS.SampleFormatType.Sfloat:
                return(BitFormatType.SFloat);

            default:
                System.Diagnostics.Debug.Assert(false);
                return(BitFormatType.SInt);
            }
        }
        /// <summary>
        /// Set sample format.
        /// </summary>
        /// <param name="type">Sample format to be set.</param>
        public void setSampleFormat(SampleFormatType type)
        {
            ushort ns = 4;

            switch (type)
            {
            case SampleFormatType.UnsignedInteger:
                ns = 1;
                break;

            case SampleFormatType.FloatPoint:
                ns = 3;
                break;

            default:
                ns = 4;
                break;
            }
            forceAdd(new TiffInfo(TiffInfoCollection.SampleFormat, "Sample Format", ns));
        }
 public SessionStatus(StreamType streamType, int pcmDataSampleRate, int deviceSampleRate, SampleFormatType deviceSampleFormat,
     int deviceBytesPerFrame, int deviceNumChannels, int timePeriodHandledNanosec, int bufferFrameNum)
 {
     StreamType = streamType;
     PcmDataSampleRate = pcmDataSampleRate;
     DeviceSampleRate = deviceSampleRate;
     DeviceSampleFormat = deviceSampleFormat;
     DeviceBytesPerFrame = deviceBytesPerFrame;
     DeviceNumChannels = deviceNumChannels;
     TimePeriodHandledNanosec = timePeriodHandledNanosec;
     EndpointBufferFrameNum = bufferFrameNum;
 }
 public int Setup(int deviceId, DeviceType t, StreamType streamType,
     int sampleRate, SampleFormatType format, int numChannels,
     MMCSSCallType mmcssCall, MMThreadPriorityType threadPriority,
     SchedulerTaskType schedulerTask, ShareMode shareMode, DataFeedMode dataFeedMode,
     int latencyMillisec, int zeroFlushMillisec, int timePeriodHandredNanosec)
 {
     var args = new SetupArgs();
     args.deviceType = (int)t;
     args.streamType = (int)streamType;
     args.sampleRate = sampleRate;
     args.sampleFormat = (int)format;
     args.numChannels = numChannels;
     args.mmcssCall = (int)mmcssCall;
     args.mmThreadPriority = (int)threadPriority;
     args.schedulerTask = (int)schedulerTask;
     args.shareMode = (int)shareMode;
     args.dataFeedMode = (int)dataFeedMode;
     args.latencyMillisec = latencyMillisec;
     args.timePeriodHandledNanosec = timePeriodHandredNanosec;
     args.zeroFlushMillisec = zeroFlushMillisec;
     return WasapiIO_Setup(mId, deviceId, ref args);
 }
 public int InspectDevice(int deviceId, int sampleRate, SampleFormatType format, int numChannels)
 {
     var args = new InspectArgs();
     args.sampleRate = sampleRate;
     args.numChannels = numChannels;
     args.sampleFormat = (int)format;
     return WasapiIO_InspectDevice(mId, deviceId, ref args);
 }
 /// <summary>
 ///  サンプルフォーマットタイプ→有効ビット数(1サンプル1chあたり。バイト数ではなくビット数)
 /// </summary>
 /// <param name="t">サンプルフォーマットタイプ</param>
 /// <returns>有効ビット数(1サンプル1chあたり。バイト数ではなくビット数)</returns>
 public static int SampleFormatTypeToValidBitsPerSample(SampleFormatType t)
 {
     switch (t) {
     case SampleFormatType.Sint16:
         return 16;
     case SampleFormatType.Sint24:
         return 24;
     case SampleFormatType.Sint32V24:
         return 24;
     case SampleFormatType.Sint32:
         return 32;
     case SampleFormatType.Sfloat:
         return 32;
     case SampleFormatType.Sdouble:
         return 64;
     default:
         System.Diagnostics.Debug.Assert(false);
         return 0;
     }
 }
 public static BitFormatType SampleFormatTypeToBitFormatType(SampleFormatType t)
 {
     switch (t) {
     case SampleFormatType.Sint16:
     case SampleFormatType.Sint24:
     case SampleFormatType.Sint32V24:
     case SampleFormatType.Sint32:
         return BitFormatType.SInt;
     case WasapiCS.SampleFormatType.Sfloat:
         return BitFormatType.SFloat;
     default:
         System.Diagnostics.Debug.Assert(false);
         return BitFormatType.SInt;
     }
 }