Life, Audio, and Computers According to Richard
A recently graduated student trying to make my mark in the world of Digital Audio and Virtual Instruments. The blog will cover my Audio Exploits and Code and may contain some of my crazy meanderings and occasional ranting.
Thursday, April 07, 2011
A change
Anyway maybe I'll do something audio based for linux or I might even try doing something with 3D like opengl and just make something that hopefully looks cool.
Tuesday, August 17, 2010
My New VST Plugin Site
Anyway I'll still keep this blog up and will consider maybe writing stuff in it such as random thoughts that may pass through my mind.
Thursday, November 05, 2009
A Basic Sine Oscillator
I’ve decided to do my first technical post. I recently joined Google Wave and started a new wave for people to put up snippets of code to do with music DSP. Currently Google Wave is invite only, so to make sure other people don’t miss out what goes on there I decided to post it on my blog.
Below you will find the code for a basic sine Oscillator. This class could be used to generate more complex waveforms through use of Fourier. Of course running many of these Oscillators at the audio rate is not a good idea as most likely the CPU would not be able to handle it. A better way of generating more complex waveforms would be to use a bandlimited mip mapped wavetable.
One thing to Note with this class is that the process function works sample by sample and this is not recommended. A better way of doing it would be to receive a block of samples in process and store the output in there. But I will leave that for the reader to work out ;).// Oscillator.h
// A basic Class for generating a sine
#include <cmath>
class Oscillator
{
private:
float SampleRate_;
float Freq_;
float Phase_;
float PhaseInc_;
public:
Oscillator();
static const float PI;
void SetFrequency(float freq);
void SetSampleRate(float sampleRate);
float Process();
};
// Oscillator.cpp
// Main implementation of Oscillator
#include "Sine.h"
#include <cmath>
const float Oscillator::PI = 4.f * atanf(1.f);
Oscillator::Oscillator()
{
SampleRate_ = 44100.f;
Phase_ = 0;
SetFrequency(440.f);
}
void Oscillator::SetSampleRate(float sampleRate)
{
SampleRate_ = sampleRate;
SetFrequency(Freq_);
}
void Oscillator::SetFrequency(float freq)
{
Freq_ = freq;
PhaseInc_ = 2.f * PI * Freq_ / SampleRate_;
}
float Oscillator::Process()
{
// Get the current output for the current phase
float out = sinf(Phase_);
// Increment our phase
Phase_ += PhaseInc_;
// Make sure it hasn't gone too far
if (Phase_ > 2.f * PI)
Phase_ -= 2.f * PI;
return out;
}
The code below is how the class can be used. The image at the top shows what our sine looks like. In the picture I have only shown one period of the waveform. If you wish to work out how many samples are in period at a certain sample rate then this simple formula can be used:-
sample period = SampleRate / Frequency ∴ 44100 / 1000 = 44.1 samples
// Main.cpp
// This code is for testing the Oscillator class
#include "Oscillator.h"
#include <fstream>
int main()
{
Oscillator osc;
osc.SetFrequency(1000.f);
std::ofstream outFile("c:\\Temp\\SineTest.txt");
// Always make sure you check the file you are opening is safe :D
float sin[1024];
for (int i = 0; i < 1024; i++)
sin[i] = osc.Process();
for (int i = 0; i < 1024; i++)
outFile << sin[i] << std::endl;
outFile.close();
return 0;
}
I hope this has been useful and if so please leave a comment or any feedback. If your confused about anything please get in touch and I will try and help.
Friday, October 30, 2009
LastGraph
Found this interesting site called Lastgraph that allows you to graph your listening habits from last.fm. As you may or may not know about me I'm big into last.fm. It's a great website for discovering new music. Thanks to it I've discovered so much new music that I probably would never have listened to without. Stuff such as the Junior Boys that upon first glance they tick all the boxes of something I should hate, yet are actually really good!
Monday, October 26, 2009
Unyaffs Windows Binary
I recently got an Android phone, specifically the Samsung i7500. While playing around with editing the android system and playing with custom android ROMs, I noticed that Android uses IMG files which have their contents stored as YAFFS. To extract the contents of these files you have to use UNYAFFS. The trouble is this program needs to be compiled for windows. So to make life a little easier I thought I’d try and save everyone the trouble.
To get it click here.
To use the program extract the RAR file somewhere. Open up a command prompt at that location and type:-
unyaffs <image_file_name>
And on another front. I know this site doesn’t get updated much but fear not I am diligently working away on these VST plugins. But I only want to get them out in the open when they are ready. I will try and post some stuff on here soon ;)
Wednesday, July 22, 2009
Graduation
Well that time finally came as I graduated on the 16th of July. After all these years I’m now being released into the real world. So I thought I’d share some of the pictures from graduation with the world out there.
The day was really nice. There was a ceremony where we got to shake the deans hand and all that. After that there was a reception where there was free food and drink. I really wanted to get as much out of that as possible but didn’t really sadly :).
Anyway I’ve now finally qualified for a Bsc Music Technology Software Development. And hopefully in the future you’ll see my work in some VST plugin companies such as fxPansion or even Izotope plugins :D. Anyway who knows what the future holds for me.
ps. Yes I do know my tie is wrong in some of the pictures :P
Tuesday, June 30, 2009
Nord Lead 2 Rack Take Apart
Last night I decided to take apart my Nord Lead 2 synthesizer so that I could give it a clean. As I was taking it apart I decided that it would be a good idea to get pictures of it naked, as I know how much everyone likes looking at circuits.
If your curious about the main specs of the Nord Lead 2 I would recommend having a look at them at Planet Groove.
Here is the main outputs of the synth. Starting on the very left there is a PCMCIA slot for adding more storage so that more patches can be stored. Next along we have the usual MIDI in and out ports. The next 2 1/4 inch jack inputs are for a sustain and control pedal. After these 2 inputs we have 4 outputs that are used to output for each of the 4 voices as the Nord Lead 2 is 4 part multitimbral.
Once the screws were loosened the top cover could be slid off to reveal the main circuitry which is made up of a power supply convertor and another section that is for the synthesis and other DSP.
Above can be seen the main circuitry for the power supply.
Above can be seen the main synthesis circuitry. You can see the slot for the PCMCIA on the right. The ribbon controller at the bottom is connected to all the pots on the front panel of the Nord. Just above the ribbon controller is a marked chip which stores the firmware. This can be replaced is it is a DIL package.
The picture above shows the back of the front panel and the Potentiometers that are connected to the front for knob twiddling. The ribbon controller can be seen that was mentioned earlier.
Once the screws that attach the input circuitry to the front panel have been removed You can then see all the chips and switches that are part of the front. Most likely these chips are for multiplexing the controls.
Well I hope you enjoyed this. I’m sorry if some of the pictures are a little fuzzy or have a flash in them but I have a rubbish camera. Anyway thanks for looking at this. Until the next time ;)
