0
votes

okay so here is the deal..

I am capturing the audio stream from microphone via naudio WaveIn method.. Now this allows me to save my capture straight into a wav file continuously.

Now i want this wav to be continuously uploaded on my ftp account. i.e the user is rec from mic.. his input is being stored into a file..and this file is being uploaded to my ftp.

I am currently facing problems regarding file lock which certainly does not allow me to access the same file at the same time it is being written.

I would be grateful to you if you can suggest me a method to upload my stream directly to my ftp account which does not involve this file issue

This is my code for recording:

  Dim recordingFormat As New WaveFormat(8000, 16, 1)
    writer = New WaveFileWriter("recorded.wav", recordingFormat)

    waveInStream = New WaveIn()
    waveInStream.DeviceNumber = 0
    waveInStream.WaveFormat = recordingFormat
    AddHandler waveInStream.DataAvailable, AddressOf waveInStream_DataAvailable
    waveInStream.StartRecording()

And for continuously saving the stream into file:

 writer.Write(e.Buffer, 0, e.BytesRecorded)

I want this ^ to to be fed directly into the ftp buffer..

Any help will be appreciated. TIA !

2

2 Answers

0
votes

You can't upload a WAV file to an FTP server while you are still creating it. The WAV file contains some chunk sizes in its header that are not filled in until you have completed creating the WAV file.

Also, you haven't said what you are using to upload the file to FTP, but I expect most FTP file uploaders don't support the file being transferred growing in size while it is being uploaded.

0
votes

Looks like you need a timer to stop recording once in a minute, build the wav file, and start recording again while you upload the created wave file at the same time.

You can use the upload mechanism of the net framework itself to simply upload a file.

I think you will be missing 1 second every minute, not so bad.