views:

10

answers:

0

Hi everyone,

I've been trying to solve a problem which I have been stuck for weeks on! Basically, the software I am developing can record audio, and then play it back. The software can record multipule sound files, and then play them one after the other (making it seem like it is 1 continious sound file). However, the problem I am having is that from the second sound file on, there seems to be a 'ticking' over the top of the second, third, fourth (and so on) file.

This ticking is the last few milliseconds of the first sound file. The 'ticking' I am refering to is similar to the sound of a vinyl record skipping very fast.

So far I haven't been able to find the root of the problem, does anyone have any ideas in regards to what could be causing this?

Thanks

EDIT: Added some methods below.

Ok, so the following method is the replay method.

public override void Replay(long time)
    {
        if(this.StartTime <= time && this.EndTime >= time && (Speed >= 0.95 && Speed <= 1.05))
        {
            if (!locked)
            {
                locked = true;
                //close the previous stream
                CloseWaveOut();
                //open the file
                waveOut = new NativeDirectSoundOut(latency);
                mainOutputStream = CreateInputStream(outputFilename);
                if (waveOut != null && mainOutputStream != null)
                {
                    //set the time position
                    long offset = time - StartTime;
                    if (offset > 0)
                    {
                        mainOutputStream.CurrentTime = TimeSpan.FromMilliseconds(Convert.ToDouble(offset));
                    }
                    //CurrentTime = TimeSpan.FromMilliseconds(Convert.ToDouble(time - StartTime));
                    waveOut.Init(mainOutputStream);
                    ((WaveChannel32)mainOutputStream).Volume = Volume;
                    Console.WriteLine("waveOut Playing");  // Debugging purposes
                    waveOut.Play();
                }
            }
        }
    }

The following method is the record method:

        public override void Record(long time)
    {
        if (waveInStream == null && writer == null && !recorded)
        {
            //for record 
            writer = new WaveFileWriter(outputFilename, recordingFormat);
            waveInStream = new WaveInStream(deviceNumber, recordingFormat, null);
            waveInStream.DataAvailable += new EventHandler<WaveInEventArgs>(waveInStream_DataAvailable);

            waveInStream.StartRecording();
            this.StartTime = time;

            Console.Out.WriteLine("Record Method called"); // Debugging Purposes
        }
    }