Simple linux VST with source code

Official support for: energy-xt.com
RELATED
PRODUCTS

Post

This is a very simple vst plugins for linux. No params, not gui, just mono saw waveform. More examples will follow up soon.

source code is at http://www.linux-vst.com

Code: Select all

#ifndef __SYNTH__
#define __SYNTH__

// simple synth class

class CSynth
{
	protected:
		int rate;
		double vol;
		double freq, phase;	
		bool playing;
	public:
		CSynth();
		void midiInput(int data);
		void process(float* p1, float* p2, int samples);
		void setRate(int val) { rate = val; }
};

CSynth :: CSynth()
{
	vol = 0.25;
	playing = false;
	rate = 44100;
}

// convert note to hertz

double noteToHz(int note)
{
	return (440 / (float)32) * pow(2, ( (note - 9) / (float)12) );
}

// handle midi input

void CSynth :: midiInput(int data)
{

	unsigned char status = data & 0xF0;
	unsigned char byte1 = (data >> 8) & 0xFF;
	unsigned char byte2 = (data >> 16) & 0xFF;

	// note on

	if (status == 0x90 && byte2 > 0) 
	{
		phase = 0;
		freq = 2 * noteToHz(byte1) / rate;
		playing = true;
	}

	// note off

	else if (status == 0x80 || (status == 0x90 && byte2 == 0)) 
	{
		playing = false;
	}

	// control change

	else if (status == 0xB0) 
	{
		// todo
	}

}

// synthesize

void CSynth :: process(float* p1, float* p2, int samples)
{

	int i;

	if (playing)
	{

		for (i = 0; i < samples; i++)
		{	

			*p1 = (float) (*p1 + phase * vol);
			*p2 = (float) (*p2 + phase * vol);

			p1++;
			p2++;

			phase = phase + freq;
			if (phase > 1)
				phase -= 2;

		}

	}

}

#endif
easy as hell :hihi:

cheers
jorgen
Last edited by jorgen on Sat Dec 16, 2006 2:55 pm, edited 2 times in total.
Half developer half human
XT Software
http://www.energy-xt.com

Post

But will it work on Suse and Feisty Fawn?

Come to that why can't I record 32 audio tracks on my 386 running Win 3.1?

Dyne:Bolic... Looks great - as silent as the grave....

s.

Post

nice...havent messed with coding in a few years--maybe ill try something now that i have a market that isnt *so* flooded with mediocre work, which is what i'll probably produce, if that :hihi:



ps, whats the "easiest" type of plugin to try and code, besides this "example"?

:oops:
i am me and i am free...k thx bai

Post

Cool jorgen.

This will help me write in Windows as well I think and that midi input section tells me the first thing I needed to know about processing midi.

I'm looking forward to more examples - especially those that process midi specifically.

Regards
Caleb
Happiness is the hidden behind the obvious.

Post

I haven't attempted to code any VSTs, but that code does look pretty simple and I have no background in C++ (I'm assuming thats what it is because of the classes).

I have spent some time with Ruby (also OOP).

Post

heh, I am super tired, and only know Java and PHP, but if I squint real hard I can almost follow that code. I love how that's something he considers "easy as hell". Makes me feel like a mental midget :(

Post

Lines like this "unsigned char byte1 = (data >> 8) & 0xFF" threw me off until I realised - hey he's done the work for me. Just drop it in the code and don't worry about it.

I was hoping I wouldn't have to deal with >> and & operators. I only ever taught myself C (a long time ago) and at the time I couldn't wrap my head around the practical application of bitwise operators like these but I think example projects may give me a "get out of jail free" card.

If only Python was the high performance plug-in language of choice. I was struggle alot less. :D

Regards
Caleb
Happiness is the hidden behind the obvious.

Post

All the programmers I know say that programming languages are more like dialects, once you understand the logic behind one you can easily port that knowledge to others.

I probably don't understand Delphi then, because I don't get C. :hihi:

Cool template though, Jørgen. I understand most of it and appreciate the gesture.

Those of you who DO get it: get busy, alright?
Rakkervoksen

Post

Where can I download the skins?

Post

www.refx.net but it's $20

Post

jorgen wrote:This is a very simple vst plugins for linux. No params, not gui, just mono saw waveform. More examples will follow up soon.

source code is at http://www.energy-xt.com/source/synth.tar.gz

Code: Select all

#ifndef __SYNTH__
#define __SYNTH__

#endif
easy as hell :hihi:

cheers
jorgen

Nice from you Jörgen, but why not on http://www.linux-vst.com/ ????

I don't think that this is the right place for coders and also in my article about your VST on Linux leading to that url... this article will be published on Sunday or Monday on www.pro-linux.de and it will be the first news about eXT2 and VST on Linux in Germany. Many coders and users reading this site and it's pure marketing for you.

So don't be shy, the world is waiting for you ;)
Last edited by Lump on Sat Dec 16, 2006 2:45 am, edited 1 time in total.
[del]AudioLinux sucks.[/del]

Post

Hey - let's have it on both I say.
Saves me having to go to two URLs. :D

OK - I'm lazy, I admit it.

I like what you're doing by the way Lump.

Regards
Caleb
Happiness is the hidden behind the obvious.

Post

awesome! I can't wait to see more.

Post

:cool: very simple (if not the simplest as it doesn't even use any controls) and hence easy indeed.

If you're new to this, don't forget to get the SDK files (from Steinberg) and put them into the directory you specified in the "compile" file which jorgen included in the archive.
You'll also find examples in the SDK, but they are a bit more advanced than this, but they as well can be adjusted to compile on linux.

Post

plastique, did you manage to compile on linux?

cheers
jorgen
Half developer half human
XT Software
http://www.energy-xt.com

Post Reply

Return to “energyXT”