Forums

    20 posts

  • avatar
    37 sounds
    86 posts
    Sound Waveform to PNG or JPG


    Waveform to PNG or JPG

    does anyone know of a windows based solution for auto generating images from wav files?

    Im basically looking to create wavform images like you have here on the free sound project

    any and all help would be greatly appreciated.

    Thanks so much.

  • avatar
    18 sounds
    456 posts


    Hmm, I once did search for this type of software, but hadn't really found anything (I did find some software generating sounds from images, based on colours), but since freesound 2.0 is going to be open source (read the blog), maybe you can find useful code in there?

  • avatar
    37 sounds
    86 posts


    Wow didn't know it was going to be open source , thats crazy smile

  • avatar
    18 sounds
    456 posts


    Yeah, it's awesome smile Coded in Python too btw.
    It's over here: [link]

  • avatar
    121 sounds
    1545 posts


    you'll need:

    http://github.com/bram/freesound/blob/34606cd534ce7b3bbb59ba1e4c8fbdcb85d4e863/freesound/utils/audioprocessing/processing.py
    http://github.com/bram/freesound/blob/34606cd534ce7b3bbb59ba1e4c8fbdcb85d4e863/freesound/utils/audioprocessing/wav2png.py

    and then also install numpy, PIL and scikits.audiolab (which needs libsndfile).

    you can remove any reference to simplejson, you don't need it for wav2png.

    - bram

    Warning: if you break the rules, see my avatar. Freesound Admin, Moderator, Ex-Freesound-Coder & Benevolent Dictator For Life.
  • avatar
    37 sounds
    86 posts


    Bram you are the Man.

    Seriously.

    smile

  • avatar
    121 sounds
    1545 posts


    remember: if you make any changes/improvements, let me know (that's the idea of GPL right wink)!

    - bram

    Warning: if you break the rules, see my avatar. Freesound Admin, Moderator, Ex-Freesound-Coder & Benevolent Dictator For Life.
  • avatar
    37 sounds
    86 posts


    Hahah yea it is.

    Im a php guy, but i have python installed on my server (dedicated) ill have to have the admin install "numpy, PIL and scikits.audiolab (which needs libsndfile)"

    Going to need to do some reading smile

    If i make any changes ill pass them back.

    Thanks for what you've done for the music community Bram smile

  • avatar
    0 sounds
    5 posts


    Just wondering if someone managed to compile the previous wav2png version (not the one in Python, but in C++) for a Mac (Intel)?
    I would be very interested in a binary...

    Bye.

    http://www.sounddesigners.org French sound addicts community
  • avatar
    121 sounds
    1545 posts


    why would you use the previous one if the new one is VASTLY superior (makes nicer pictures, uses MUCH less memory)?

    - bram

    Warning: if you break the rules, see my avatar. Freesound Admin, Moderator, Ex-Freesound-Coder & Benevolent Dictator For Life.
  • avatar
    121 sounds
    1545 posts


    btw, make sure you get the very latest from http://github.com/bram/freesound/tree/master/freesound/utils/audioprocessing/

    - bram

    Warning: if you break the rules, see my avatar. Freesound Admin, Moderator, Ex-Freesound-Coder & Benevolent Dictator For Life.
  • avatar
    0 sounds
    5 posts


    Thanks Bram, i already tried the latest Python release (with all libraries), but can't make it work under OS X.5.8... Getting a "ImportError: cannot import name Tester" concerning numpy.testing. XCode and MacPorts up to date here.

    Same goes for the latest original release of wav2png, i can't compile it under OS X (through MacPorts), getting "../../src/main.cpp:827: error: ‘gdImageDestroy’ was not declared in this scope" when compiling.

    No problem under Ubuntu though...

    I only need black&white imaging and the resolution scaling feature, so a simple binary (Mac Intel) would be great for me...

    Bye.

    http://www.sounddesigners.org French sound addicts community
  • avatar
    0 sounds
    5 posts


    No one able to compile a Mac intel binary for us ? Please ? wink

    Bye.

    http://www.sounddesigners.org French sound addicts community
  • avatar
    1490 sounds
    1590 posts


    Hello All,

    Slightly related subject... so I decided to post here in case anyone finds it useful.
    Many (and i mean MANY) years ago I toyed with converting images to sounds and vice-versa. I produced a couple of really nice samples (which by the way, I will now track and post in freesound grin ).

    The idea of getting involved with programming or compiling any code in order to do this freezes the blood in my veins... So if you are like me, read on for an alternative process...

    1) Find a graphics program that supports saving in RAW format. - plenty of free ones should be available or you may already have one that supports this format.
    2) Find a sound editor that supports RAW format. - Again, you should be able to find a free one or maybe your current one already supports this format.
    3) Use the graphics program to convert your picture to RAW
    4) Load it up into the sound editor.

    Some hints on picture to sound convertion:
    I have found that "texture" sort of pictures tend to produce the best results. (The sort of pics that you would use as tiles for a Windows backdrop). Photos of yourself or your cat are more likely to sound as raw data (which, of course is what they are). The sort of seamless wood, stone, water or other textures for backdrops tend to produce a more "textured noise" sort of result.
    Also, I would suggest using black and white pics or converting to black and white (alternatively, you can save only the Red, Green or Blue component of your picure, if your graphics software allows this option). The reason for this is that the graphics program will save the three colour layers (R,G,B) and usually a further luminance layer in sequence for colour pics. When converted to audio, you end up with a sound that contains 3 or 4 nearly identical bursts of noise. Of course you can save as coulor and then simply edit the sound to cut any unwanted parts.

    If you are doing the opposite process - i.e., trying to load up a soundfile as a picture
    1) convert the sound file to RAW format and save using the sound editor program
    2) load it up into the graphics program. - at this point the graphics program will probably ask you for the size (width x height) of the picture, colour depth and weather it is B&W or Colour. (This because when saved as RAW there is no information on the file from which the graphics program can extract these settings). You may have to experiment with different import parameters to get the most "usable" pictures.

    Hints:
    Suggest you import as B&W - colour will usually produce pictures that just look like random noise since the sound data will be split into 3 or 4 chunks and assigned to R, G, B and possible luminance.
    Experiment with importing the same sound file with different weight x height and bit depth combinations. (if you are a bit of a geek, you can even work the best combinations out using the file size, so you do not cut part of the data out or end up with a portion of blank space at the end of the picture).
    What I would look for and I suggest produces best results is to experiment with different import parameters until you get a B&W picture where you can clearly see a "pattern". This works with tonal monophonic sounds such as a note from a guitar, bass or flute. Generlly it will not work well with noise, tracks containing multiple instruments or atonal sounds like drums).
    When you have obtained one such picture with a more or less obvious pattern, applying image processing effects such as contrast, blur, pixelate or smear is more likely to produce a result which, when converted back to sound still retains some "musicality".
    If you do any "image" processing on your sound file wthout first having obtained this "patternet picture" the result wil, almost always just sound as raw noise when converted back to audio.

    Have fun !!!

    hmmmm..... erm..... I forgot...
  • avatar
    18 sounds
    456 posts


    That sounds interesting. I haven't done much experimenting with this in the past, but I'll try it.
    How about reversing the process? What image do you get if you import a simple sine wave, for example?

  • avatar
    1490 sounds
    1590 posts


    The answer is NOT straightforward.

    With the process I mentioned on my post, the sounds are converted from the original format (say, WAV) to RAW.
    This means that some important info is lost in the process, such as bit depth and sample rate. Even a sound editor will require you to supply this information manually if you load it up again.

    The same applies to a graphics program importing RAW files: user needs to provide some parameters to the program so it can make sense of the data.

    To answer your question.
    Even the the exact same RAW file can be made to look quite different when imported as a picture - this because the RAW format file contains no indicators which will allow the graphics program to make sense of the data. Therefore, it will ask the user to provide image widht, heigh, bit depth and "colour encoding" (there are different standards:black&white, RGB, Luma/Chroma,...). Enter different parameters and you get different images.

    For a sound made up of a simple constant waveform, you should obtain an image that clearly shows a "pattern". Especially if imported as a black and white picture. When I am at home later I will try to upload some pictures which illustrate what I am talking about.
    The patterns can be less obvious for complex sounds (e.g. piano). And you may be unable to obtain a pattern from less harmonic sounds such as a cymbal or speech.

    By the way, if anyone uses VST plugins and wants to explore further the image to sound conversion and vice-versa, the KVR Dec plugin competition is now on. Some of the entries are VST plugnis that do precisely these conversions.
    Due to interference from the day job :wink: , I have not tried these VSTs yet, but anyone can download them for free. Have a look at
    http://www.kvraudio.com/developer_challenge_2009.php

    This conversation has obviously enticed me to go back and create some noise using these processes.
    Will be posting the results with the tag "image-to-sound" on Freesound. Expect some uploads after the weekend...

    hmmmm..... erm..... I forgot...
  • avatar
    18 sounds
    456 posts


    Yes of course, makes sense. I had some fun trying to get a Blender 'Wood' texture (basically a series of black and white wavy lines, with some minor noise) to audio, but GIMP wouldn't allow me to use 'raw' as extension. Tiff worked rather well, but I do believe bmp should be pretty raw (afaik, it's simply a list of bgr (blue green red) codes in a continuous line), but haven't tried it. Another problem was, while it produced some remarkable sound-like waves, the waves were 'inverted', meaning what's usually the top part of a wave was way at the bottom and the bottom part was at the top. This produced a nasty noise, while the underlying sound was fairly interesting.
    I did some experiments in the past converting audio to text (very short samples) and found that for 16 bit samples the center line has hex value 0000, -15 dB(fs) on the plus side has value 16C3, -3 dB on the plus side has value 5A9F, 0 dB on the plus side (max height) is 7FFF and the next number in line, 8000 corresponds to 0 dB (max height) on the minus side, so it completely flips the wave here.
    So you have
    0000 - 7FFF is center line - 0 dB plus
    8000 - FFFF is 0 dB minus - center line

    That should mean if you have a black image with a white, blurry line on it, everything that's black is on the center line, where the blurring starts, the wave goes up towards the top. Where the blurry part is 50% grey, the wave hits the top and flip down to the bottom at the next sample. From there it continues up again until full white. From there the blurring starts again back to black, the wave going down towards bottom, where the blurry is grey again, the wave hits bottom and jumps up to the top on next sample. As blurring goes down into black, wave goes back to center line.
    In theory! (If I understand correctly) This seems to be correct with my earlier test in mind, the image went from black to white and back a few times, all the time flipping the wave when it hit top or bottom.
    I should do some more tests.
    And maybe we should do this in a new thread tongue

  • avatar
    1490 sounds
    1590 posts


    Hello nemoDaedalus,

    Great discussion here. Plenty of things for me to try when I get home!

    I know exactly what you mean when you say the waveform is flipped.

    Some graphics programs may allow you to "cycle" the colours, so that you can start with a "black picture with a blurry white line on it" and then cycle through the (gryescale). Shifting throug the grayscale like this, you can obtain a file where the soundwave is positioned correctly.

    I used to have the same problem of flipped waveforms when I tried to import audio files from the PC into an Amiga computer.

    Rather than start a new thread, should we ask one of the moderators to move the thread to a more suitable Forum?
    Would you be interested in doing some collaboration on image-to-sound and sound-to-image ?

    Cesar / AlienXXX

    hmmmm..... erm..... I forgot...
  • avatar
    18 sounds
    456 posts


    Yeah, I'm sure the topic can be split?
    While I can open anything in Audacity, I couldn't yet get GIMP to open sounds.

    [edit]
    Heh, this is quite cool. I took the Wood texture from Blender's procedural texture, shifted the shades of grey using Curves, saved the result as bmp and imported the bmp as raw audio in Audacity using settings 16-bit signed, big-endian, mono, 44k1Hz.
    The weird line at the beginning of the file you see here is the bmp header. I left it on, but you could easily set a higher start position on import. I did crop the sound after importing.
    Note in GIMP how the image is greyscale, but it goes from black to a light grey. It doesn't go up all the way to white. Due to this, there was a bit of negative bias on the wav. I corrected this later.
    The resulting wav is uploaded and now awaiting moderation. smile

    http://s4.postimage.org/4HkX9.jpg

    [/edit]

  • avatar
    1490 sounds
    1590 posts


    OK, great.

    I am assuming once the sound is approved you will be posting the link. grin
    May I suggest you do so in a new post in a more appropriate forum and also post the link to this initial discussion? grin

    We will continue the discussion in the new thread and I will be posting my sonic (miss)adventures on the new thread as well.

    With regards to the blip cause by the bmp header, I had the same problem too. I mean ultimately, you can import ANY kind of file as a RAW file... Even if you have to manually edit the file name to change it from bmp or GIF or whatever to RAW.
    The problem is that you do get the file header. You can edit it out, but the problem is that it is not exactly obvious where the header finishes when you are looking at a sound file on a graphics editor or at a picture on a sound editor...
    That is why I prefer to actually convert to RAW format - absolutely no header data at all.

    On another matter, you are using GIMP. Are you working on a Linux machine?
    I have not installed Audacity, but I have heard great things about this program, so I might install it in th enear future.

    Moderator's note: This line of thought is continued in this thread.

    hmmmm..... erm..... I forgot...

    20 posts