public static AVSampleFormat GetSampleFormat(this AudioDataFormat dataFormat) { switch (dataFormat.BytesPerSample) { case 1 when dataFormat.NumberFormat == NumberFormat.Unsigned: return(AVSampleFormat.AV_SAMPLE_FMT_U8); case 2 when dataFormat.NumberFormat == NumberFormat.Signed: return(AVSampleFormat.AV_SAMPLE_FMT_S16); case 4 when dataFormat.NumberFormat == NumberFormat.FloatingPoint: return(AVSampleFormat.AV_SAMPLE_FMT_FLT); case 4 when dataFormat.NumberFormat == NumberFormat.Signed: return(AVSampleFormat.AV_SAMPLE_FMT_S32); case 8 when dataFormat.NumberFormat == NumberFormat.FloatingPoint: return(AVSampleFormat.AV_SAMPLE_FMT_DBL); case 8 when dataFormat.NumberFormat == NumberFormat.Signed: return(AVSampleFormat.AV_SAMPLE_FMT_S64); default: throw new ArgumentOutOfRangeException(); } }
/// <param name="configuration"> Audio encoding or filtering related configuration </param> /// <param name="frameConsumer"> Consumer for the produced audio frames </param> /// <param name="volumeLevel"> Mutable volume level for the audio </param> /// <param name="outputFormat"> Output format to use throughout this processing cycle </param> public AudioProcessingContext(AudioConfiguration configuration, AudioFrameConsumer frameConsumer, AtomicInteger volumeLevel, AudioDataFormat outputFormat) { this.configuration = configuration; this.frameConsumer = frameConsumer; this.volumeLevel = volumeLevel; this.outputFormat = outputFormat; }
/// <param name="timecode"> Timecode of this frame in milliseconds. </param> /// <param name="data"> Buffer for this frame, in the format specified in the format field. </param> /// <param name="volume"> Volume level of the audio in this frame. </param> /// <param name="format"> Specifies the format of audio in the data buffer. </param> public AudioFrame(long timecode, sbyte[] data, int volume, AudioDataFormat format) { this.timecode = timecode; this.data = data; this.volume = volume; this.format = format; }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: @Override public void encode(java.io.DataOutput out, TrackStartRequestMessage message) throws java.io.IOException public void encode(DataOutput @out, TrackStartRequestMessage message) { int version = version(message); @out.writeLong(message.executorId); @out.writeUTF(message.trackInfo.title); @out.writeUTF(message.trackInfo.author); @out.writeLong(message.trackInfo.length); @out.writeUTF(message.trackInfo.identifier); @out.writeBoolean(message.trackInfo.isStream); @out.writeInt(message.encodedTrack.Length); @out.writeBytes(message.encodedTrack.ToString()); @out.writeInt(message.volume); @out.writeUTF(message.configuration.getResamplingQuality().ToString()); @out.writeInt(message.configuration.OpusEncodingQuality); if (version >= VERSION_WITH_FORMAT) { AudioDataFormat format = message.configuration.OutputFormat; @out.writeInt(format.channelCount); @out.writeInt(format.sampleRate); @out.writeInt(format.chunkSampleCount); @out.writeUTF(format.codec.name()); } if (version >= VERSION_WITH_POSITION) { @out.writeLong(message.position); } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: @Override public TrackStartRequestMessage decode(java.io.DataInput in, int version) throws java.io.IOException public TrackStartRequestMessage decode(DataInput @in, int version) { long executorId = @in.readLong(); AudioTrackInfo trackInfo = new AudioTrackInfo(@in.readUTF(), @in.readUTF(), @in.readLong(), @in.readUTF(), @in.readBoolean(), null); sbyte[] encodedTrack = new sbyte[@in.readInt()]; @in.readFully(encodedTrack); int volume = @in.readInt(); AudioConfiguration configuration = new AudioConfiguration(); configuration.ResamplingQuality = AudioConfiguration.ResamplingQuality.valueOf(@in.readUTF()); configuration.OpusEncodingQuality = @in.readInt(); if (version >= VERSION_WITH_FORMAT) { AudioDataFormat format = new AudioDataFormat(@in.readInt(), @in.readInt(), @in.readInt(), AudioDataFormat.Codec.valueOf(@in.readUTF())); configuration.OutputFormat = format; } long position = 0; if (version >= VERSION_WITH_POSITION) { position = @in.readLong(); } return(new TrackStartRequestMessage(executorId, trackInfo, encodedTrack, volume, configuration, position)); }
/// <param name="audioTrack"> The audio track that this executor executes </param> /// <param name="configuration"> Configuration to use for audio processing </param> /// <param name="volumeLevel"> Mutable volume level to use when executing the track </param> /// <param name="useSeekGhosting"> Whether to keep providing old frames continuing from the previous position during a seek /// until frames from the new position arrive. </param> /// <param name="bufferDuration"> The size of the frame buffer in milliseconds </param> public LocalAudioTrackExecutor(InternalAudioTrack audioTrack, AudioConfiguration configuration, AtomicInteger volumeLevel, bool useSeekGhosting, int bufferDuration) { this.audioTrack = audioTrack; AudioDataFormat currentFormat = configuration.OutputFormat; this.frameBuffer = new AudioFrameBuffer(bufferDuration, currentFormat, isStopping); this.processingContext = new AudioProcessingContext(configuration, frameBuffer, volumeLevel, currentFormat); this.useSeekGhosting = useSeekGhosting; }
public static extern int SDL_BuildAudioCVT( out SDL_AudioCVT cvt, AudioDataFormat src_format, byte src_channels, int src_rate, AudioDataFormat dst_format, byte dst_channels, int dst_rate );
/// <param name="bufferDuration"> The length of the internal buffer in milliseconds </param> /// <param name="format"> The format of the frames held in this buffer </param> public AudioFrameBuffer(int bufferDuration, AudioDataFormat format, AtomicBoolean stopping) { synchronizer = new object(); fullCapacity = bufferDuration / 20 + 1; _audioFrames = new BlockingCollection <AudioFrame> /*<AudioFrame>*/ (fullCapacity); this.format = format; this.stopping = stopping; terminated = false; terminateOnEmpty = false; clearOnInsert = false; receivedFrames = false; }
public AudioConversion( AudioDataFormat sourceFormat, byte sourceChannels, int sourceRate, AudioDataFormat destinationFormat, byte destinationChannels, int destinationRate ) { needed = ErrorIfNegative(SDL_BuildAudioCVT( out conversion, sourceFormat, sourceChannels, sourceRate, destinationFormat, destinationChannels, destinationRate)); }
public int version(RemoteMessage message) { // Backwards compatibility with older nodes. if (message is TrackStartRequestMessage) { if (((TrackStartRequestMessage)message).position != 0) { return(VERSION_WITH_POSITION); } AudioDataFormat format = ((TrackStartRequestMessage)message).configuration.OutputFormat; if (!format.Equals(StandardAudioDataFormats.DISCORD_OPUS)) { return(VERSION_WITH_FORMAT); } return(VERSION_INITIAL); } return(VERSION_WITH_POSITION); }
/// <summary> /// Create a new configuration with default values. /// </summary> public AudioConfiguration() { resamplingQuality = ResamplingQuality.LOW; opusEncodingQuality = OPUS_QUALITY_MAX; outputFormat = StandardAudioDataFormats.DISCORD_OPUS; }
public static void Open(int frequency, AudioDataFormat format, int channels, int chunksize) { ErrorIfNegative(Mix_OpenAudio(frequency, (ushort)format, channels, chunksize)); }
public void Deconstruct(out int sampleRate, out int channels, out AudioDataFormat dataFormat) { sampleRate = SampleRate; channels = Channels; dataFormat = DataFormat; }
public static bool IsInteger(AudioDataFormat format) { return(!format.HasFlag(AudioDataFormat.IsFloat)); }
public static byte BitSize(AudioDataFormat format) { return((byte)(format & AudioDataFormat.SizeMask)); }
public static bool IsUnsigned(AudioDataFormat format) { return(!format.HasFlag(AudioDataFormat.IsSigned)); }
public static bool IsLittleEndian(AudioDataFormat format) { return(!format.HasFlag(AudioDataFormat.IsBigEndian)); }
public static bool IsBigEndian(AudioDataFormat format) { return(format.HasFlag(AudioDataFormat.IsFloat)); }
public static extern void SDL_MixAudioFormat( byte *dst, /*const*/ byte *src, AudioDataFormat format, uint len, int volume);
public AudioFormat(int sampleRate, int channels, AudioDataFormat dataFormat) { SampleRate = sampleRate; Channels = channels; DataFormat = dataFormat; }