Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 7 of 7

Thread: Instructions or tutorials for using wav2sketch?

  1. #1

    Instructions or tutorials for using wav2sketch?

    Are there more detailed step by step instructions somewhere for using wav2sketch to convert .wav files to data arrays? "The wav2sketch program can convert WAV files to the data arrays needed by AudioPlayMemory" isn't very illuminating, at least for me who's more of a GUI/WYSIWYG guy. My searches haven't revealed detailed instructions.

    I see links to some C source code and a Window executable. I don't know how you make C source code run in Terminal on a Mac. Initial searches indicate installing developer tools. I don't poke around in Terminal that much; it frightens me a bit.

    I attempted to launch the Windows .exe in Windows 8 in VMWare Fusion, but nothing visible happened when I tried to run the .exe. I'm not a Windows guy, either.

    After a lot of troubleshooting I was able to get a modified version of the SamplePlayer example sketch to play through the Teensy 3.2 DAC and into my little Sparkfun amp and small speaker. My next step is to try to replace those sounds with the two sound effects I need for my project, hence this request for help.

    Thank you.


  2. #2
    Senior Member+ manitou's Avatar
    Join Date
    Jan 2013
    The wav2sketch program looks for *.wav files in your current directory and creates .h and .cpp files to put in your sketch folder.

    So if you download wav2sketch.exe into your windows Downloads folder, then put your .wav files in the Downloads folder and open a command window in the Downloads folder (or cd to it). Then run wav2sketch from the command window

    for linux, compile wav2sketch.c and run it in directory with your .wav files
    Last edited by manitou; 02-27-2017 at 02:57 PM.

  3. #3
    Senior Member
    Join Date
    May 2015
    It's amazing to me how often people ask a question or talk about I feature, library or tool that I didn't even know existed that is perfect for something I'm about to do. I hadn't yet got into playing waves for canned sounds but just when I start thinking along those lines a post starts with all I could have wanted to know. The same with actual working code to have USB audio without an audio board, the Snooze library and more. A big thanks to Paul and the fantastic community here. Far better that some other arm communities/chip sets I tried in the past.

  4. #4
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    You're going to have to run it in Terminal. Here's a copy compiled for macintosh.
    Attached Files Attached Files

  5. #5
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    To use this, first create an empty folder. I made a folder called "wav2sketch" from my home dir. Put the zip file in that folder and extract it. Also put some WAV files in the folder. This program converts whatever WAV files happen to be in the same folder.

    Open Terminal.

    To get set up, you're going to type 3 commands. First use "cd wav2sketch" (or whatever folder name you used) to change the current working directory to the folder you created. Then type "ls -l" to see a list of files. The only reason for "ls -l" it to make sure you've successfully changed to the folder where you put this stuff. If your Terminal opens with you using a different folder, you're going to have to fiddle with "cd" commands until you manage to get to the folder you created.

    Click image for larger version. 

Name:	sc1.png 
Views:	187 
Size:	363.1 KB 
ID:	9848
    (click for full size)

    Once you get to the folder and you can see the files with "ls -l", there's one more prep command to type: "chmod 755 wav2sketch". This sets the execute permission, so you can actually run the file. Like most unix commands "no news is good news", it prints nothing if it works. See the screenshot above.

    Then to run it, type "./wav2sketch". If you get "Permission Denied" the chmod command didn't work. If it works, it'll print a few lines telling you what it did (not the normal "no news" unix approach). You should see something like this:

    Click image for larger version. 

Name:	sc2.png 
Views:	144 
Size:	398.8 KB 
ID:	9849
    (click for full size)

    Probably best to do with with a familiar Finder window open next to Terminal, as I did for these screenshots. When it works, you'll see the Arduino compatible .cpp and .h files appear. Or you can type "ls -l" in Terminal, but at this point you can just quit Terminal and use the files.

  6. #6
    Thanks, Paul, for taking the time to compile the code and create these step-by-step instructions for someone like me who's not savvy working in a command line environment. I appreciate the help.

    I'll give this a go.



  7. #7
    Junior Member
    Join Date
    Feb 2018
    Oopps I cannot open this mac version, there is no link?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts