private static void ConvertSamples(IntPtr In, ASIOSampleType Type, IntPtr Out, int Count) { switch (Type) { //case ASIOSampleType.Int16MSB: //case ASIOSampleType.Int24MSB: //case ASIOSampleType.Int32MSB: //case ASIOSampleType.Float32MSB: //case ASIOSampleType.Float64MSB: //case ASIOSampleType.Int32MSB16: //case ASIOSampleType.Int32MSB18: //case ASIOSampleType.Int32MSB20: //case ASIOSampleType.Int32MSB24: case ASIOSampleType.Int16LSB: Audio.Util.LEi16ToLEf64(In, Out, Count); break; //case ASIOSampleType.Int24LSB: case ASIOSampleType.Int32LSB: Audio.Util.LEi32ToLEf64(In, Out, Count); break; case ASIOSampleType.Float32LSB: Audio.Util.LEf32ToLEf64(In, Out, Count); break; case ASIOSampleType.Float64LSB: Audio.Util.CopyMemory(Out, In, Count * sizeof(double)); break; //case ASIOSampleType.Int32LSB16: //case ASIOSampleType.Int32LSB18: //case ASIOSampleType.Int32LSB20: //case ASIOSampleType.Int32LSB24: default: throw new NotImplementedException("Unsupported sample type"); } }
/// <summary> /// Selects the sample convertor based on the input WaveFormat and the output ASIOSampleTtype. /// </summary> /// <param name="waveFormat">The wave format.</param> /// <param name="asioType">The type.</param> /// <returns></returns> public static SampleConvertor SelectSampleConvertor(WaveFormat waveFormat, ASIOSampleType asioType) { SampleConvertor convertor = null; bool is2Channels = waveFormat.Channels == 2; // TODO : IMPLEMENTS OTHER CONVERTOR TYPES switch (asioType) { case ASIOSampleType.ASIOSTInt32LSB: switch (waveFormat.BitsPerSample) { case 16: convertor = (is2Channels) ? (SampleConvertor)ConvertorShortToInt2Channels : (SampleConvertor)ConvertorShortToIntGeneric; break; case 32: convertor = (is2Channels) ? (SampleConvertor)ConvertorFloatToInt2Channels : (SampleConvertor)ConvertorFloatToIntGeneric; break; } break; case ASIOSampleType.ASIOSTInt16LSB: switch (waveFormat.BitsPerSample) { case 16: convertor = (is2Channels) ? (SampleConvertor)ConvertorShortToShort2Channels : (SampleConvertor)ConvertorShortToShortGeneric; break; case 32: convertor = (is2Channels) ? (SampleConvertor)ConvertorFloatToShort2Channels : (SampleConvertor)ConvertorFloatToShortGeneric; break; } break; case ASIOSampleType.ASIOSTInt24LSB: switch (waveFormat.BitsPerSample) { case 16: throw new ArgumentException("Not a supported conversion"); case 32: convertor = ConverterFloatTo24LSBGeneric; break; } break; case ASIOSampleType.ASIOSTFloat32LSB: switch (waveFormat.BitsPerSample) { case 16: throw new ArgumentException("Not a supported conversion"); case 32: convertor = ConverterFloatToFloatGeneric; break; } break; default: throw new ArgumentException( String.Format("ASIO Buffer Type {0} is not yet supported.", Enum.GetName(typeof(ASIOSampleType), asioType))); } return convertor; }
/// <summary> /// Selects the sample convertor based on the input WaveFormat and the output ASIOSampleTtype. /// </summary> /// <param name="waveFormat">The wave format.</param> /// <param name="asioType">The type.</param> /// <returns></returns> public static SampleConvertor SelectSampleConvertor(WaveFormat waveFormat, ASIOSampleType asioType) { SampleConvertor convertor = null; bool is2Channels = waveFormat.Channels == 2; if (waveFormat.BitsPerSample != 16 && waveFormat.BitsPerSample != 32) { throw new ArgumentException(String.Format("WaveFormat BitsPerSample {0} is not yet supported", waveFormat.BitsPerSample)); } // TODO : IMPLEMENTS OTHER CONVERTOR TYPES switch (asioType) { case ASIOSampleType.ASIOSTInt32LSB: switch (waveFormat.BitsPerSample) { case 16: convertor = (is2Channels) ? ConvertorShortToInt2Channels : (SampleConvertor)ConvertorShortToIntGeneric; break; case 32: convertor = (is2Channels) ? ConvertorFloatToInt2Channels : (SampleConvertor)ConvertorFloatToIntGeneric; break; } break; case ASIOSampleType.ASIOSTInt16LSB: switch (waveFormat.BitsPerSample) { case 16: convertor = (is2Channels) ? ConvertorShortToShort2Channels : (SampleConvertor)ConvertorShortToShortGeneric; break; case 32: convertor = (is2Channels) ? ConvertorFloatToShort2Channels : (SampleConvertor)ConvertorFloatToShortGeneric; break; } break; default: throw new ArgumentException( String.Format("ASIO Buffer Type {0} is not yet supported. ASIO Int32 buffer is only supported.", Enum.GetName(typeof(ASIOSampleType), asioType))); } return(convertor); }
public Channel(ASIOChannelInfo Info) { index = Info.channel; name = Info.name; type = Info.type; }
public Buffer(ASIOBufferInfo Info, ASIOSampleType Type, int Count) { info = Info; type = Type; samples = new Audio.SampleBuffer(Count); }
public BufferInfo(ASIOBufferInfo Info, ASIOSampleType Type) { info = Info; type = Type; }
private static void ConvertSamples(IntPtr In, IntPtr Out, ASIOSampleType Type, int Count) { switch (Type) { //case ASIOSampleType.Int16MSB: //case ASIOSampleType.Int24MSB: //case ASIOSampleType.Int32MSB: //case ASIOSampleType.Float32MSB: //case ASIOSampleType.Float64MSB: //case ASIOSampleType.Int32MSB16: //case ASIOSampleType.Int32MSB18: //case ASIOSampleType.Int32MSB20: //case ASIOSampleType.Int32MSB24: case ASIOSampleType.Int16LSB: Audio.Util.LEf64ToLEi16(In, Out, Count); break; //case ASIOSampleType.Int24LSB: case ASIOSampleType.Int32LSB: Audio.Util.LEf64ToLEi32(In, Out, Count); break; case ASIOSampleType.Float32LSB: Audio.Util.LEf64ToLEf32(In, Out, Count); break; case ASIOSampleType.Float64LSB: Audio.Util.CopyMemory(Out, In, Count * sizeof(double)); break; //case ASIOSampleType.Int32LSB16: //case ASIOSampleType.Int32LSB18: //case ASIOSampleType.Int32LSB20: //case ASIOSampleType.Int32LSB24: default: throw new NotImplementedException("Unsupported sample type"); } }