Friday, May 25, 2012

Recording Music from a Musical Instrument

You can record high quality audio by direct cable connection between your computer and musical instrument (such as musical keyboard, electric guitar).

You need a two way audio cable. (with 3.5mm TRS connectors). Just connect it to audio out of the instrument and line-in/mic of the computer.
Most of the instruments have a 6.35mm socket for audio output. In that case you also need a 6.35mm male to 3.5mm female jack stereo audio adapter. You can get these from a local electronics store or a site like amazon, ebay.

Moving on to software, you don't need expensive professional sound editing software. Audacity is a free and open source cross-platform audio recorder/editor and perfectly fits our purpose.
 
Next comes the tricky part. During recording, you hear what you play through the computer. If there's a delay between what you play and what you hear, it's very difficult to play. Let's look at solutions for this.

Windows

When it comes to Windows, drivers pass sound through the system kernel, resulting considerable amount of latency.
This won't be a big issue on sound cards that support ASIO. ASIO is a sound card driver  protocol that minimizes the latency by bypassing operating system layers and connecting directly to the soundcard. However, not many soundcards support ASIO (specially integrated audio chipsets).

ASIO4ALL may help you in this case. It is an independent universal emulated ASIO driver and brings ASIO support to virtually all consumer-grade soundcards and integrated audio chipsets.
The problem here is that, you need a recording program that supports ASIO. Though Audacity can support ASIO, they don't distribute it with ASIO support since it's proprietary and has an incompatible license. You maybe able to find an unofficial version with ASIO support to download, or if you are a software geek, you can compile Audacity yourself with ASIO support.

Linux

Most modern distributions (Ubuntu, Fedora, Mint, OpenSUSE)  use PluseAudio with ALSA. Usually it results in lower latencies. If you are lucky, you may be able to record without any tweaking.
Within audacity, just goto Edit -> Preferences -> Recording and select Software Playthorugh.

If you experience some delay, you can route the input at PulseAudio level by engaging loopback module. Goto terminal and execute:
pactl unload-module module-loopback
In my experience, this can also have some latency, and if your computer (laptop) has a built in microphone, you might get a loud noise.

What worked best for me is using the pacat command. What we do here is capturing the raw audio steam from the specific device we want and playing it back from the output device on the fly, specifying minimum latency. You can quickly get this working by following these instructions. Make sure you have selected "pulse" as both playback and recording device in Audacity Preferences -> Devices, otherwise you won't be able to record while pacat is active.

After you have recorded, you can easily get the mp3 by using Audacity's Export command.

Here is a recording I made. This is a part of the song "Never Forget" in Halo3. Played with Yamaha PSR-E323. Recorded with Audacity in Linux with the last technique above.
Never Forget (cover) by Amila Manoj

3 comments:

Erika said...

Beautiful! Thank you for posting your recording.

I am also looking to record with Audacity on my PC, from the same keyboard you are using. I haven't done this before so I am trying to see where everything connects.

Forgive my ignorance :) but is the "line out" actually the headphones "out"? Or did you use the MIDI? I originally thought that the MIDI was what I would be using to connect to my computer but I have been reading MIDI that it doesn't provide the audio information that Audacity needs to record, so I ran across your blog post.

I want to make sure I know the right connectors to use before I go buy them :)

Thanks again for your post, your recording sounds awesome!

Erika

Amila Manoj said...

Hey Erika,

Thanks for your feedback. :)

Yes, what you need to use is audio-out (line-out / headphone) of your musical keyboard. The cable I've shown in this blog post is the one you should get, not a MIDI cable.

MIDI is a different technology which is used to record musical information, not actual audio. It's for different purposes and there are other software to capture MIDI information.

Cheers,
Amila

Guzzi sager said...

Very informative and worthy post. Thanks for the sharing such a precious updates with us.

Samsung - ATIV Book 9 Plus Ultrabook 13.3" Touch-Screen Laptop - 4GB Memory - 128GB Solid State Drive - Ash Black

Samsung - ATIV Book 7 13.3" Touch-Screen Laptop - 4GB Memory - 128GB Solid State Drive - Ash Black