• Audio files and endianness

    From Nightfox@VERT/DIGDIST to All on Monday, May 16, 2011 18:06:00
    Recently I've been working on an application which will involve reading & writing WAV audio files. I've read that the WAV file specification specifies that WAV files are little-endian. Does anyone know if audio data needs to be treated differently on big-endian computers? I imagine you'd need to convert the audio samples to big-endian before doing any audio processing, and then convert the audio samples back to little-endian before saving to disk, but I'm not sure if audio processing software just leaves the samples as-is. Audio processing often involves mathematics though, so I imagine that not honoring the computer's endianness could be bad..

    Nightfox

    ---
    þ Synchronet þ Digital Distortion BBS - digdist.bbsindex.com
  • From Digital Man@VERT to Nightfox on Monday, May 16, 2011 19:15:39
    Re: Audio files and endianness
    By: Nightfox to All on Mon May 16 2011 06:06 pm

    Recently I've been working on an application which will involve reading & writing WAV audio files. I've read that the WAV file specification
    specifies that WAV files are little-endian. Does anyone know if audio data needs to be treated differently on big-endian computers? I imagine you'd need to convert the audio samples to big-endian before doing any audio processing, and then convert the audio samples back to little-endian before saving to disk, but I'm not sure if audio processing software just leaves the samples as-is. Audio processing often involves mathematics though, so
    I imagine that not honoring the computer's endianness could be bad..

    WAV file format is a Microsoft/IBM creation for Windows/PCs, so they do store multi-byte integers in little endian. What big endian platforms would you be modifying WAV files on?

    digital man

    Synchronet "Real Fact" #68:
    You can purchase the BBS Documentary DVD set at http://bbsdocumentary.com/order/

    ---
    þ Synchronet þ Vertrauen þ Home of Synchronet þ telnet://vert.synchro.net
  • From Nightfox@VERT/DIGDIST to Digital Man on Tuesday, May 17, 2011 07:51:39
    Re: Audio files and endianness
    By: Digital Man to Nightfox on Mon May 16 2011 19:15:39

    WAV file format is a Microsoft/IBM creation for Windows/PCs, so they do stor multi-byte integers in little endian. What big endian platforms would you be modifying WAV files on?

    Even though the WAV format was originall made for Windows/PCs, it's a fairly common format, and there are editors available for PowerPC Mac, for instance. Audacity is an example of an audio editor that is available in a PowerPC Mac version that can edit WAV files:
    http://audacity.sourceforge.net
    I'm sure there are others.. Also, iTunes (at least the Windows version) supports playing WAV files - I'm not sure how long iTunes has been able to, but I'd guess the Mac version can probably play WAV files too.

    Besides WAV files, MP3 files are a cross-platform standard, so I imagine endianness is more of an issue with MP3s - My question would apply to MP3s too..

    Anyway, if I'm developing an app that deals with modifying audio files, I'm not sure how much sense it would make to have it use one format on one platform but a different format on another.. unless one format used on one platform was totally rare on the other platform - then I think it would make more sense to support different format standards on different platforms.

    Nightfox

    ---
    þ Synchronet þ Digital Distortion BBS - digdist.bbsindex.com
  • From John Guillory@VERT/MAINLINE to Nightfox on Saturday, May 21, 2011 14:10:19
    Re: Audio files and endianness
    By: Nightfox to All on Mon May 16 2011 06:06 pm

    Recently I've been working on an application which will involve reading & writing WAV audio files. I've read that the WAV file specification
    specifies that WAV files are little-endian. Does anyone know if audio data needs to be treated differently on big-endian computers? I imagine you'd need to convert the audio samples to big-endian before doing any audio processing, and then convert the audio samples back to little-endian before saving to disk, but I'm not sure if audio processing software just leaves the samples as-is. Audio processing often involves mathematics though, so
    I imagine that not honoring the computer's endianness could be bad..
    .WAV files are designed by Microsoft for Windows, so naturally it'd be little endian format. I'd imagine if playing on a big-endian machine, you'd want to convert them to big-endian first before playing or editing them, then convert them back to little-endian. I may be wrong as it's been a long time since I've messed around with digital audio processing. Last time I did was DOS in turbo pascal, using a Sound Blaster 16 if that gives you an idea.


    ---
    þ Synchronet þ Roach Guts - roachguts.com
  • From Nightfox@VERT/DIGDIST to John Guillory on Saturday, May 21, 2011 17:39:15
    Re: Audio files and endianness
    By: John Guillory to Nightfox on Sat May 21 2011 14:10:19

    .WAV files are designed by Microsoft for Windows, so naturally it'd be littl endian format. I'd imagine if playing on a big-endian machine, you'd want t convert them to big-endian first before playing or editing them, then conver them back to little-endian. I may be wrong as it's been a long time since I

    That's what I'm thinking too..

    Nightfox

    ---
    þ Synchronet þ Digital Distortion BBS - digdist.bbsindex.com
  • From Tracker1@VERT/TRN to Nightfox on Sunday, May 22, 2011 17:37:41
    On 5/16/2011 6:06 PM, Nightfox wrote:
    Recently I've been working on an application which will involve reading& writing WAV audio files. I've read that the WAV file specification specifies that WAV files are little-endian. Does anyone know if audio data needs to be treated differently on big-endian computers? I imagine you'd need to convert the audio samples to big-endian before doing any audio processing, and then convert the audio samples back to little-endian before saving to disk, but I'm
    not sure if audio processing software just leaves the samples as-is. Audio processing often involves mathematics though, so I imagine that not honoring the computer's endianness could be bad..

    What about SDL?

    Depending on what you are doing, you may want to use a class library that already handling the WAV files to a native audio stream for whatever conversions you are wanting to make... you'd need to handle the WAV data by reading in each character/byte/integer etc at a time and converting... this is rather cumbersome and odds are someone has already done it.

    --
    Michael J. Ryan - http://tracker1.info/

    ---
    þ Synchronet þ Roughneck BBS - telnet://roughneckbbs.com - www.roughneckbbs.com
  • From Nightfox@VERT/DIGDIST to Tracker1 on Sunday, May 22, 2011 22:30:42
    Re: Re: Audio files and endianness
    By: Tracker1 to Nightfox on Sun May 22 2011 17:37:41

    What about SDL?

    Depending on what you are doing, you may want to use a class library that already handling the WAV files to a native audio stream for whatever conversions you are wanting to make...

    I wasn't aware of SDL.. But I've been working on developing my own WAV file I/O class, partly because I want the experience of doing it myself, and also because I want said class to be independent of any other libraries - A long time ago, I was creating an app where I grabbed someone else's WAV file class and used it in my project, but their WAV file class relied on DirectX. I've done a WAV file class from scratch in C# already, and I think it's a good exercise. C++ has its own unique challenges.

    you'd need to handle the WAV data by
    reading in each character/byte/integer etc at a time and converting... this rather cumbersome and odds are someone has already done it.

    Yep. I don't think it's really cumbersome though. On a big-endian machine, if you're reading 16-bit audio samples into variables of 'short' data type, swapping the byte order would take just one line of code in C++. If the variable is called audioSample, you can do this: std::reverse((char*)&audioSample, ((char*)&audioSample)+2);

    Nightfox

    ---
    þ Synchronet þ Digital Distortion BBS - digdist.bbsindex.com