Archive for the ‘ C++ ’ Category

DIY Condenser Microphone

Sunday, November 28th, 2010

After much thought on which audio gear to acquire for guitar recording, I came across forums discussing DIY condenser microphones. This is the one I purchased for around $12 CAD. You can also spend an extra 5 dollars for preassembled kit if you prefer not to solder all the pieces together. There are also schematics online without a big fat PCB board which I will attempt next time. Since I’ve yet a hardware mixer to plug with a better cable,  I’ve wired this to a 3.5mm jack for the time being to test on my Auzentech Prelude sound card. It’s powered by a 9 volt battery, and the circuit seems to produce a really loud output. So the 3.5mm jack is actually connected to an audio cable with volume control to reduce the volume. And it works quite well.

Here is an audio recording sample of guitar: Mic Demo

The microphone capsules work well, but I’m wondering if it could be better by replacing them with the WM-61a panasonic capsules that majority of the DIY enthusiasts seemed to vote for. Those are in transit and will post updates later. I’ve also ordered 1/4″ inline jack for use when I get my hardware mixer. There’s still a fair bit of noise I must admit, but that may be attributed by various factors, once I have the mixer to test with, I will hopefully be able to reduce the noise.

Waveloop – Wave looping cmdline tool

Sunday, September 26th, 2010

Being a producer of custom sound samples, I’ve came across the problem of sound looping of my samples in the past. To achieve this, I manually construct a fades in audacity to create loop point. But this is tedious work, especially with hundreds (if not thousands) of audio samples to go through. To ease this process, I did what I do best, automate via scripts. The choice of tool was AutoIt (Windows Only). This was a GUI automation scripting tool. Works wonders, but I soon found it tedious to run each script manually. So I ventured forth by using the C# api from AutoIt to automate so I can parse input files for batch edits. But the overhead from the GUI automation was still making the whole process slow. Not to mention the change in Audacity’s processes, it made automation a bit difficult. I also tried to port the C# code to C++ but that was left unfinished (mostly because of the release of Battlefield Bad Company 2).

So recently I decided to give the direct wave file manipulation a go. I came across multiple open source libraries that can parse headers and read / write to wave files. Finally ended up working with the Synthesis Toolkit (STK). Some other libraries include the RIFF class from libgig which can be found in Linuxsampler (really good), CLAM (C++ Library for Audio and Music), looks like an extensive library but the installation instructions was a massive turn off, Libsndfile (good for multi formats). There were also a few other libraries I found but they seemed to be geared towards video games audio, bit of an overkill.

After a few hours of work, I’ve finished a simple command line wave looping tool in c++ in Codeblocks.

Waveloop - Loop tool

There are at least 4 required fields:

  1. filein – the input file name
  2. loopstart – the starting point of loop (can be in seconds or sample #)
  3. loopend – the ending point of the loop (can be in seconds or sample #)
  4. xfadelength – the cross fade length (can be in seconds or sample #)

Notice that when you input in seconds, you need to prefix the parameters with “s”.

For some apparent reason, the reading utility from STK doesn’t seem to read the inputs consistently in terms of normalization, so I’ll have to dig into this. Therefore, files parsed by the waveloop utility are all normalized to peak at 0db. I’ve only tested it with 16bit and 24bit Wave files currently, but according to STK specifications, 32bit samples should work as well. Multichannel files are supported. Only uses linear fading for now, I’m not sure if there’s a need for other interpolated fades. I should also point out that currently, anything after the “loopEnd” will be trimmed off. In the future, I might want to fade the tail to create release samples.

This is also my first time using Codeblocks, all I can say is that it’s horrible. I’ve used Visual Studio and Eclipse for C++ environments, and I have to say that the codeblocks autocomplete is the worst by far.

Download: Waveloop Utility for Windows 0.1a (GNU General Public License V3)
Mac and Linux ports are pending consideration…

The next update will include csv/xml file parsing for batch edits. Stay tuned!

Feedbacks are welcome!

[Update 09/27/2010] – Fixed normalization bug, now output file data is no longer normalized.