Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Design and Architecture
  4. Recording a wave file

Recording a wave file

Scheduled Pinned Locked Moved Design and Architecture
csharpdesignperformancehelpquestion
5 Posts 3 Posters 4 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    Leslie Sanford
    wrote on last edited by
    #1

    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?

    L 1 Reply Last reply
    0
    • L Leslie Sanford

      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?

      L Offline
      L Offline
      Luc Pattyn
      wrote on last edited by
      #2

      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] }


      L 1 Reply Last reply
      0
      • L Luc Pattyn

        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] }


        L Offline
        L Offline
        Leslie Sanford
        wrote on last edited by
        #3

        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! :)

        L C 2 Replies Last reply
        0
        • L Leslie Sanford

          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! :)

          L Offline
          L Offline
          Luc Pattyn
          wrote on last edited by
          #4

          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] }


          1 Reply Last reply
          0
          • L Leslie Sanford

            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! :)

            C Offline
            C Offline
            Chris Kaiser
            wrote on last edited by
            #5

            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.

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups