Exemplo n.º 1
0
 protected virtual void OnDataReady(SoundDataReadyEventArgs dataSet)
 {
     if (DataReady != null)
     {
         DataReady(this, dataSet);
     }
 }
Exemplo n.º 2
0
 private void silencerLoop(SoundDataReadyEventArgs dataSet, int start, int end)
 {
     for (int i = start; i < end; i++)
     {
         dataSet.SoundData[i] /= volumeDownValue;
     }
 }
Exemplo n.º 3
0
 private void OnThreadReady(SoundDataReadyEventArgs dataSet)
 {
     if (ThreadReady != null)
     {
         ThreadReady(this, dataSet);
     }
 }
Exemplo n.º 4
0
        protected void OnDataReady()
        {
            SoundDataReadyEventArgs dataSet = new SoundDataReadyEventArgs(SoundDataBuffer.Size, frequency, SoundDataBuffer.PopAll(), false);

            adsKill = new Thread(() => ads.Process(dataSet));
            adsKill.Start();
            dataSet.DataParcelNumber = ++bufferCounter;
        }
Exemplo n.º 5
0
        //protected void OnStopMe()
        //{

        //    if (Stop != null)
        //    {
        //        Stop(this, EventArgs.Empty);
        //    }
        //}
        protected override void HandleDataReady(object sender, SoundDataReadyEventArgs args)
        {
            StatusText = "Buffering ...";
            SoundDataBuffer.Push(args.SoundData);
            if (SoundDataBuffer.Size > bufferTime)
            {
                this.OnDataReady();
            }
        }
Exemplo n.º 6
0
        private void adKilling(ref SoundDataReadyEventArgs dataSet, int start, int end)
        {
            if (start > -1)
            {
                newStartJingleLength = 0;

                if (start + startJingle.SoundDataBuffer.Buffer.Length >= dataSet.SoundData.Length)
                {
                    newStartJingleLength = startJingle.SoundDataBuffer.Buffer.Length - (dataSet.SoundData.Length - start);
                    dataSet.AdState      = true;
                }
                else
                {
                    if (end > -1)
                    {
                        if (end >= dataSet.SoundData.Length)
                        {
                            this.silencerLoop(dataSet, start + startJingle.SoundDataBuffer.Buffer.Length, dataSet.SoundData.Length);
                            dataSet.AdState = true;
                        }
                        else
                        {
                            this.silencerLoop(dataSet, start + startJingle.SoundDataBuffer.Buffer.Length, end);
                            dataSet.AdState = false;
                        }
                    }
                    else
                    {
                        this.silencerLoop(dataSet, start + startJingle.SoundDataBuffer.Buffer.Length, dataSet.SoundData.Length);
                        dataSet.AdState = true;
                    }
                }
            }
            else
            {
                if (dataSet.AdState)
                {
                    if (end > -1)
                    {
                        if (end >= dataSet.SoundData.Length)
                        {
                            this.silencerLoop(dataSet, newStartJingleLength, dataSet.SoundData.Length);
                        }
                        else
                        {
                            this.silencerLoop(dataSet, newStartJingleLength, end);
                            dataSet.AdState = false;
                        }
                    }
                    else
                    {
                        this.silencerLoop(dataSet, newStartJingleLength, dataSet.SoundData.Length);
                    }
                    newStartJingleLength = 0;
                }
            }
        }
Exemplo n.º 7
0
        private void OnDataReady()
        {
            dataSet = new SoundDataReadyEventArgs(buffer.Length, frequency, buffer, false);
            dataSet.LastDataParcel   = endOfFile;
            dataSet.DataParcelNumber = dataCounter;

            if (DataReady != null)
            {
                DataReady(this, dataSet);
            }
        }
Exemplo n.º 8
0
        private FMOD.RESULT PcmReadCallbackStream(IntPtr soundraw, IntPtr data, uint datalen)
        {
            lock (readLock)
            {
                SoundDataReadyEventArgs playData = new SoundDataReadyEventArgs((int)datalen / sizeof(short), frequency);
                Marshal.Copy(data, playData.SoundData, 0, (int)datalen / sizeof(short));
                base.OnDataReady(playData);
            }

            return(FMOD.RESULT.OK);
        }
Exemplo n.º 9
0
        protected override void HandleDataReady(object sender, SoundDataReadyEventArgs args)
        {
            lock (thisLock)
            {
                readySound.Sounds.addSoundData(args.SoundData);

                if (!playSoundOnce)
                {
                    readySound.Sounds.PlayCheckedSound();
                    playSoundOnce = true;
                }
            }
            Debug.WriteLine(String.Format("{0}{1}", "Something", Thread.CurrentThread.ManagedThreadId));
        }
Exemplo n.º 10
0
        protected override void HandleDataReady(object sender, SoundDataReadyEventArgs args)
        {
            lock (thisLock)
            {
                frequency = args.Frequency;
                short[] addtionalData = new short[addtionalDataBufferTime * channelCount * frequency];

                if (args.DataParcelNumber == 1)
                {
                    dataBuffer  = new short[args.SoundData.Length];
                    soundBuffer = new CircularBuffer(args.SoundData.Length);
                    soundBuffer.Push(args.SoundData);
                    Array.Copy(args.SoundData, dataBuffer, args.SoundData.Length);
                }
                else
                {
                    Array.Copy(args.SoundData, 0, addtionalData, 0, addtionalData.Length);
                    soundBuffer.Push(addtionalData);
                    DetectionResult detectionTimes = SoundProcessor.DetectJingle(soundBuffer.Buffer, startJingle.SoundDataBuffer.Buffer, endJingle.SoundDataBuffer.Buffer);

                    SoundDataReadyEventArgs dataSet = new SoundDataReadyEventArgs(dataBuffer.Length, frequency, dataBuffer, adState);

                    adKilling(ref dataSet, detectionTimes.StartJingleIndex, detectionTimes.EndJingleIndex);
#if DEBUG
                    Debug.WriteLine(detectionTimes.StartJingleIndex / (double)(frequency * sizeof(short)));
                    Debug.WriteLine(detectionTimes.EndJingleIndex / (double)(frequency * sizeof(short)));
#endif

                    base.OnDataReady(dataSet);
                    soundBuffer = new CircularBuffer(args.SoundData.Length);
                    soundBuffer.Push(args.SoundData);
                    adState = dataSet.AdState;

                    dataBuffer = new short[args.SoundData.Length];
                    Array.Copy(args.SoundData, dataBuffer, args.SoundData.Length);

                    if (args.LastDataParcel)
                    {
                        detectionTimes = SoundProcessor.DetectJingle(soundBuffer.Buffer, startJingle.SoundDataBuffer.Buffer, endJingle.SoundDataBuffer.Buffer);
                        adKilling(ref dataSet, detectionTimes.StartJingleIndex, detectionTimes.EndJingleIndex);
#if DEBUG
                        Debug.WriteLine(detectionTimes.StartJingleIndex / (double)(frequency * sizeof(short)));
                        Debug.WriteLine(detectionTimes.EndJingleIndex / (double)(frequency * sizeof(short)));
#endif
                        base.OnDataReady(dataSet);
                    }
                }
            }
        }
Exemplo n.º 11
0
 protected abstract void HandleDataReady(object source, SoundDataReadyEventArgs args);
Exemplo n.º 12
0
 protected void HandleThreadReady(object sender, SoundDataReadyEventArgs args)
 {
     base.OnDataReady(args);
 }
Exemplo n.º 13
0
 public void Process(SoundDataReadyEventArgs dataSet)
 {
     dataSet.CheckNull("thread dataSet");
     OnThreadReady(dataSet);
 }
Exemplo n.º 14
0
 protected override void HandleDataReady(object source, SoundDataReadyEventArgs args)
 {
     throw new NotImplementedException();
 }