Recording a wave file
-
I've written a synth toolkit in C#. I'm adding the capability to record the output as a wave file. I'm trying to nail down the design for doing this. Here's the approach I currently have implemented:
-
User hits record (a check box with a button appearance).
-
Synth engine begins recording output memory
-
User hits record a second time
-
Synth engine stops recording
-
User is prompted and asked if he/she wants to save the wave data
-
If user says yes, the user is prompted for a file name, and the wave data in memory is saved to disk
-
If user says no, wave data is cleared
The problem with the above is that wave data takes up a lot of memory. If the user wants to record for say an hour or so, he/she could run out of memory. I found this out when I forgot to stop recording and ate dinner. When I came back, the computer was slugish due to low memory. So I was thinking that a better approach would be to record directly to disk:
-
User hits record (a check box with a button appearance).
-
Synth engine begins recording output to a temporary file
-
User hits record a second time
-
Synth engine stops recording
-
User is prompted and asked if he/she wants to save the wave data
-
If user says yes, the user is prompted for a file name, and the temporary file is renamed to the new name
-
If user says no, the temporary file is deleted
Perhaps I should set a limit on how large a file is acceptable so that it's not possible for the program to use up all available disk space. Hmm, maybe I could use that approach for recording to memory instead? Any thoughts? Details I may be overlooking?
-
-
I've written a synth toolkit in C#. I'm adding the capability to record the output as a wave file. I'm trying to nail down the design for doing this. Here's the approach I currently have implemented:
-
User hits record (a check box with a button appearance).
-
Synth engine begins recording output memory
-
User hits record a second time
-
Synth engine stops recording
-
User is prompted and asked if he/she wants to save the wave data
-
If user says yes, the user is prompted for a file name, and the wave data in memory is saved to disk
-
If user says no, wave data is cleared
The problem with the above is that wave data takes up a lot of memory. If the user wants to record for say an hour or so, he/she could run out of memory. I found this out when I forgot to stop recording and ate dinner. When I came back, the computer was slugish due to low memory. So I was thinking that a better approach would be to record directly to disk:
-
User hits record (a check box with a button appearance).
-
Synth engine begins recording output to a temporary file
-
User hits record a second time
-
Synth engine stops recording
-
User is prompted and asked if he/she wants to save the wave data
-
If user says yes, the user is prompted for a file name, and the temporary file is renamed to the new name
-
If user says no, the temporary file is deleted
Perhaps I should set a limit on how large a file is acceptable so that it's not possible for the program to use up all available disk space. Hmm, maybe I could use that approach for recording to memory instead? Any thoughts? Details I may be overlooking?
Hi Leslie, I would suggest you add an options dialog, that lets the user choose the maximum capture period (say radio buttons for 10 sec, 1 min, 10 min; or a textbox); then have the record button record to memory for that time (or until clicked again), then do the save/saveto dialog stuff you described. I would not automatically save to temp file on disk, unless you take some precautions limiting both the size and the number of such files; without limits, you may find yourself cleaning up the disk quite often. :)
Luc Pattyn
try { [Search CP Articles] [Search CP Forums] [Forum Guidelines] [My Articles] } catch { [Google] }
-
-
Hi Leslie, I would suggest you add an options dialog, that lets the user choose the maximum capture period (say radio buttons for 10 sec, 1 min, 10 min; or a textbox); then have the record button record to memory for that time (or until clicked again), then do the save/saveto dialog stuff you described. I would not automatically save to temp file on disk, unless you take some precautions limiting both the size and the number of such files; without limits, you may find yourself cleaning up the disk quite often. :)
Luc Pattyn
try { [Search CP Articles] [Search CP Forums] [Forum Guidelines] [My Articles] } catch { [Google] }
Luc Pattyn wrote:
I would suggest you add an options dialog, that lets the user choose the maximum capture period (say radio buttons for 10 sec, 1 min, 10 min; or a textbox); then have the record button record to memory for that time (or until clicked again), then do the save/saveto dialog stuff you described.
That sounds excellent. Will do. Thanks! :)
-
Luc Pattyn wrote:
I would suggest you add an options dialog, that lets the user choose the maximum capture period (say radio buttons for 10 sec, 1 min, 10 min; or a textbox); then have the record button record to memory for that time (or until clicked again), then do the save/saveto dialog stuff you described.
That sounds excellent. Will do. Thanks! :)
Glad to help. The more challenging option could be: record for ... sec/min or [checkbox] until 3 sec of silence occurs. :-D
Luc Pattyn
try { [Search CP Articles] [Search CP Forums] [Forum Guidelines] [My Articles] } catch { [Google] }
-
Luc Pattyn wrote:
I would suggest you add an options dialog, that lets the user choose the maximum capture period (say radio buttons for 10 sec, 1 min, 10 min; or a textbox); then have the record button record to memory for that time (or until clicked again), then do the save/saveto dialog stuff you described.
That sounds excellent. Will do. Thanks! :)
Also, you could add in support for both. This way for people who wish to record large amounts they have the option of recording to hard disk. But also include a restraint option in the config dialog similar to what you'll have for in memory recording.
This statement was never false.