Beispiel #1
0
 internal void InternalSetPitch(float pitch)
 {
     if (m_audioTrack != null)
     {
         int x = (int)((float)SamplingFrequency * pitch);
         x = MathUtils.Min(x, 2 * AudioTrack.GetNativeOutputSampleRate(Stream.Music));
         Mixer.CheckTrackStatus((TrackStatus)m_audioTrack.SetPlaybackRate(x));
     }
 }
        public AsyncPlayer(SineWaveGenerator generator)
        {
            this.generator = generator;

            var streamType = Stream.Music;
            var sampleRate = AudioTrack.GetNativeOutputSampleRate(streamType);
            var encoding   = Android.Media.Encoding.Pcm16bit;
            var bufferSize = AudioTrack.GetMinBufferSize(sampleRate, ChannelOut.Mono, encoding) + 2;

            Log.Info("AudioInit", "{0} / {1}", sampleRate, bufferSize);

            soundTrack = new AudioTrack(streamType,
                                        sampleRate,
                                        ChannelConfiguration.Mono,
                                        encoding,
                                        bufferSize,
                                        AudioTrackMode.Stream);
            soundBuffer = new short [bufferSize];

            processThread = new Thread(ThreadStart);
        }