Beispiel #1
0
        public StereoSample GetSample()
        {
            StereoSample newSample = new StereoSample();
            for (int i = 0; i < this.Inputs.Count; i++)
            {
                StereoSample sample = this.Inputs[i].GetSample();
                if (this.EnableLimiting && (int)(newSample.LeftSample + sample.LeftSample) > short.MaxValue)
                {
                    newSample.LeftSample = short.MaxValue;
                }
                else
                {
                    newSample.LeftSample += sample.LeftSample;
                }

                if (this.EnableLimiting && (int)(newSample.RightSample + sample.RightSample) > short.MaxValue)
                {
                    newSample.RightSample = short.MaxValue;
                }
                else
                {
                    newSample.RightSample += sample.RightSample;
                }
            }

            return newSample;
        }
Beispiel #2
0
        public StereoSample GetSample()
        {
            StereoSample newSample = new StereoSample();

            for (int i = 0; i < this.Inputs.Count; i++)
            {
                StereoSample sample = this.Inputs[i].GetSample();
                if (this.EnableLimiting && (int)(newSample.LeftSample + sample.LeftSample) > short.MaxValue)
                {
                    newSample.LeftSample = short.MaxValue;
                }
                else
                {
                    newSample.LeftSample += sample.LeftSample;
                }

                if (this.EnableLimiting && (int)(newSample.RightSample + sample.RightSample) > short.MaxValue)
                {
                    newSample.RightSample = short.MaxValue;
                }
                else
                {
                    newSample.RightSample += sample.RightSample;
                }
            }

            return(newSample);
        }
        protected override void GetSampleAsync(MediaStreamType mediaStreamType)
        {
            for (int i = 0; i < numSamples; i++)
            {
                StereoSample sample;
                if (this.Input != null)
                    sample = this.Input.GetSample();
                else
                    sample = new StereoSample();

                //left channel
                memoryStream.WriteByte(
                    (byte)(sample.LeftSample & 0xFF));
                memoryStream.WriteByte(
                    (byte)(sample.LeftSample >> 8));


                //right channel
                memoryStream.WriteByte(
                        (byte)(sample.RightSample & 0xFF));
                memoryStream.WriteByte(
                        (byte)(sample.RightSample >> 8));

            }

            MediaStreamSample mediaStreamSample =
                new MediaStreamSample(mediaStreamDescription, memoryStream, currentPosition,
                                      bufferByteCount, currentTimeStamp, emptySampleDict);

            currentTimeStamp += bufferByteCount * 10000000L / byteRate;
            currentPosition += bufferByteCount;

            ReportGetSampleCompleted(mediaStreamSample);
        }
Beispiel #4
0
        public virtual StereoSample GetSample()
        {
            StereoSample sample = this.Input.GetSample();

            sample.LeftSample  = this.Attenuate(sample.LeftSample);
            sample.RightSample = this.Attenuate(sample.RightSample);
            return(sample);
        }
Beispiel #5
0
        public StereoSample GetSample()
        {
            StereoSample sample = this.Input.GetSample();

            sample.LeftSample  = this.Attenuate(sample.LeftSample, this.leftMultiplier);
            sample.RightSample = this.Attenuate(sample.RightSample, this.rightMultiplier);
            return(sample);
        }
        protected override void GetSampleAsync(MediaStreamType mediaStreamType)
        {
            for (int i = 0; i < numSamples; i++)
            {
                StereoSample sample;
                if (this.Input != null)
                {
                    sample = this.Input.GetSample();
                }
                else
                {
                    sample = new StereoSample();
                }

                //left channel
                memoryStream.WriteByte(
                    (byte)(sample.LeftSample & 0xFF));
                memoryStream.WriteByte(
                    (byte)(sample.LeftSample >> 8));


                //right channel
                memoryStream.WriteByte(
                    (byte)(sample.RightSample & 0xFF));
                memoryStream.WriteByte(
                    (byte)(sample.RightSample >> 8));
            }

            MediaStreamSample mediaStreamSample =
                new MediaStreamSample(mediaStreamDescription, memoryStream, currentPosition,
                                      bufferByteCount, currentTimeStamp, emptySampleDict);

            currentTimeStamp += bufferByteCount * 10000000L / byteRate;
            currentPosition  += bufferByteCount;

            ReportGetSampleCompleted(mediaStreamSample);
        }