RavenBlog
Black:  ravenblack.net | me | games | books | email | wishlist | rss
Blogs:  Angryblog | As Above | MonkyBlog | Nightshade | Journals
Blimey:  SomethingAwful | Advice
Archives: Last 4 Days | June2001 | July2001 | August2001 | September2001 | October2001 | November2001 | December2001 | January2002 | February2002 | March2002 | April2002 | May2002 | June2002 | July2002 | August2002 | September2002 | October2002 | November2002 | December2002 | January2003 | February2003 | March2003 | April2003 | May2003 | June2003 | July2003 | August2003 | September2003 | October2003 | November2003 | December2003 | January2004 | February2004 | March2004 | April2004 | May2004 | June2004 | July2004 | August2004 | September2004 | October2004 | November2004 | December2004 | January2005 | February2005 | March2005 | April2005 | May2005 | June2005 | July2005 | August2005 | September2005 | October2005 | November2005 | January2006 | February2006 | March2006 | April2006 | May2006 | June2006 | July2006 | August2006 | September2006 | October2006 | November2006 | December2006 | January2007 | February2007 | March2007 | April2007 | May2007 | June2007 | July2007 | August2007 | September2007 | October2007 | November2007 | December2007 | January2008 | February2008 | March2008 | April2008 | May2008 | June2008 | July2008 | August2008 | September2008 | October2008 | November2008 | December2008 | January2009 | March2009 | April2009 | May2009 | July2009 | August2009 | September2009 | February2010 | March2010 | June2010 | July2010 | August2010 | September2010 | October2010 | November2010 | December2010 | February2011 | March2011 | April2011 | May2011 | June2011 | July2011 | August2011 | September2011 | October2011 | December2011 | March2012 | April2012 | May2012 | September2012 | December2012 | March2013 | April2013 | May2013 | June2013 | October2021


Comments on Friday 8 February 2008:
A post for programmers who are being frustrated with bad documentation - Google didn't help me, but once it indexes this it might help someone else. In programming audio in the latest DirectX "hey it's Monday again, let's make everything work another new totally different way" upgrade to audio functionality, there is a function
HRESULT IXACTWave::SetPitch(XACTPITCH pitch)
About which the documentation says "The value of pitch may be between XACTPITCH_MIN (-1200) and XACTPITCH_MAX (1200), which is approximately one semitone."

Now the astute amongst you might realise that already this is annoying and ambiguous - what is approximately one semitone? The distance between -1200 and 1200, which is 2400, or a distance of 1200? Also, what the hell, when you're changing pitch by playing the sample at a different frequency you can easily go up and down by a whole octave by doubling or halving the frequency, why are you limiting me to a semitone? Well, thankfully, the answer to "which of these" is "no, it is neither of those things that could possibly be meant by that sentence."

Instead, a pitch of 1200 is approximately one octave above 0, and each 100 pitch is a semitone. So you can in fact go up and down by an octave, like you should be able to (though really there's no reason for it to disallow going two octaves if you want to, even though it'd sound crap) as well as pitching to nearby notes easily. It's a bit strange to have SetPitch operating on a linear scale like this since the change of frequency is an exponential scale, which conversion must presumably be going on behind the scenes in a manner that would be entirely unnecessary for my purposes since I could precalculate the desired frequencies, but oh well, at least it works and does what I need it to do.

Another malfunctioning function is
HRESULT IXACTWave::Stop(DWORD flags)
which "returns S_OK if successful, otherwise an error code." Except no it doesn't - if you use IXACTWaveBank::Play to start a sound, and then call Stop on the output IXACTWave pointer immediately afterwards, it returns S_OK but the wave does not in fact stop, which is horrible if the wave was set to loop indefinitely. However, you can call Destroy on the output wave object which will reliably stop it. I have no idea what's going on behind the scenes there, or whether one needs to call Destroy on every output wave pointer out of a wavebank.Play call to avoid memory leaks, because the documentation is fucking awful. Hooray.

In other good design news, installing Linux Ubuntu, the "user-friendly" desktop Linux. Step 1: graphical installer. Very posh and Windows-like. Here's a dialog box, fill it in. Here's another one to select your timezone. Oh you don't want to be able to click 'next' do you? Well good luck with that, Mr "only 800x600 screen" (or less, as, say, on an Eee machine), because that button is way off the bottom of the screen where you can't get it unless you know some arcane key-mouse combinations to work around it. This has been a known and potentially-easily-fixed issue for about two years. Oh Lunix nerds, you are so good at user interfaces.

And further on the audio front, is there really no preexisting function to make a segment of a wave file loop smoothly? It's getting to the point that I'm considering writing my own command-line wave file editor to perform the following operations:
  1. Find the zero-crossings in the same direction nearest to the given boundaries. (Existing software does this one.)
  2. Find the volume 'cone' in the selection and normalise it to a volume 'cylinder'.
  3. Also normalise into the same volume cylinder a small section out of the wave before the selected block, into a spare area.
  4. Cross-fade the spare block onto the end of the target block.
  5. Set loop point markers in the wav file at the ends of the target block. (One of the two pieces of software I tried can do this step.)
Hopefully this way I can make instrument notes where I can control the duration and volume of the note and it doesn't sound like a midi file. [13:42]
Add Comment:
Name:Comment: (max. 2048 characters)
Email:
Show Email: (if no website)
Website:
No HTML tags allowed.
(Antispam) What is 6 + 6?
Archives: Last 4 Days | June2001 | July2001 | August2001 | September2001 | October2001 | November2001 | December2001 | January2002 | February2002 | March2002 | April2002 | May2002 | June2002 | July2002 | August2002 | September2002 | October2002 | November2002 | December2002 | January2003 | February2003 | March2003 | April2003 | May2003 | June2003 | July2003 | August2003 | September2003 | October2003 | November2003 | December2003 | January2004 | February2004 | March2004 | April2004 | May2004 | June2004 | July2004 | August2004 | September2004 | October2004 | November2004 | December2004 | January2005 | February2005 | March2005 | April2005 | May2005 | June2005 | July2005 | August2005 | September2005 | October2005 | November2005 | January2006 | February2006 | March2006 | April2006 | May2006 | June2006 | July2006 | August2006 | September2006 | October2006 | November2006 | December2006 | January2007 | February2007 | March2007 | April2007 | May2007 | June2007 | July2007 | August2007 | September2007 | October2007 | November2007 | December2007 | January2008 | February2008 | March2008 | April2008 | May2008 | June2008 | July2008 | August2008 | September2008 | October2008 | November2008 | December2008 | January2009 | March2009 | April2009 | May2009 | July2009 | August2009 | September2009 | February2010 | March2010 | June2010 | July2010 | August2010 | September2010 | October2010 | November2010 | December2010 | February2011 | March2011 | April2011 | May2011 | June2011 | July2011 | August2011 | September2011 | October2011 | December2011 | March2012 | April2012 | May2012 | September2012 | December2012 | March2013 | April2013 | May2013 | June2013 | October2021