Nub and im not joking.

DSP, Plugin and Host development discussion.
RELATED
PRODUCTS

Post

Hi,
I didn't realize what goes into digital sounds (programming wise i mean).. always took it for granted that it just .. 'sounds good'.

well .. where do i start here

tell you what im going to start by asking the questions that eventually made me register here because for the love of god this digital sound business is HORRIBLY complicated! unless you've spent hours / days / months or even years researching it all.

and the read me's and tutorials i have encountered i think were written by aliens or tefal heads ( remember them ? ) ..


basic starter question :

limiter and crusher?( yes i have read up on it and nope i still don't totally understand it ) so here i go blundering in and here's mine.

here goes dont kill me ..


(double)yoursample=therealsample;
if (yoursample>32767.0)yoursample-=(yoursample/2);
if (yoursample<-32767.0)yoursample+=(yoursample/2);
therealsample=yoursample;


crude yep , agreed but works.

so im going to be honest and say i would like some pointers in the correct direction to give me some kind of idea how to implement different things regarding digital sound manipulation.


to be honest i have all ready spent far too much time on this where i could just download a dsp and 'plug it in' to my programs ( which i dont want to ) im the kind of guy who likes to be able to make it himself but where to start~?.

any help and if possible keep it simple?.
Last edited by TheTurner on Fri Nov 29, 2013 11:56 am, edited 1 time in total.

Post

A limiter limits the output volume. A bit crusher reduces the bitrate of a sound degrading the sound in the process (like old samplers do).

and it's noob, not nub. :P

Post

i know mate im not as thick as i seem , i know a limiter limits , crusher i didnt know though , never knew it changed the bitrate thats good info , if we keep up like this i wont look as stupid in ten years eh lol

and thanks for the info btw i know your trying to help.

so supposing i did something like

sambuffer[idontknow lets make it 1024*4 yeah]
sambuffer[offset++]=sample;
sambuffer[offset++]=sample;

so reduces it to half speed then if i mix the buffer the samples going to have a sample playing lower mixed with the origional , is that what you meen by bitrate?
Last edited by TheTurner on Fri Nov 29, 2013 12:05 pm, edited 2 times in total.

Post

Digital by default sounds horrible. It's only thanks to years and years of research and refinement that digital synths sound good today.
http://sendy.bandcamp.com/releases < My new album at Bandcamp! Now pay what you like!

Post

Sendy wrote:Digital by default sounds horrible. It's only thanks to years and years of research and refinement that digital synths sound good today.
100% correct , it does sound horrible i learnt that much allready.

Post

What I mean by bitrate is the number of "bits" per sample. An audio CD is 16 bit for example. Chances are your DAW can record at 16, 24 or 32 bit. I have no idea what the numbers you are using mean.

Post

This subforum of KVR is for people getting started consuming VSTs, not building it from scratch. The proper forum for this kind of stuff is the DSP subforum.
TheTurner wrote:

Code: Select all

(double)yoursample=therealsample; 
if (yoursample>32767.0)yoursample-=(yoursample/2); 
if (yoursample<-32767.0)yoursample+=(yoursample/2); 
therealsample=yoursample;
If your code receives 24bit integers or 32bit floats, then you'd have to change it. That's why in a VST the audio is always represented in floating point with values between +1.0 and -1.0.

Why first divide by 2, and then subtract it? Half plus half is one again. And then you also don't need the negative branch:

Code: Select all

if (sample > 1.0 || sample < 1.0) sample = sample / 2;
Too crude indeed. It will only work with peaks up to +6 dB. It creates huge discrepancies (audible artefacts) in the signal. Better take a transfer function that smoothes it out and can't go beyond the intended range:

Code: Select all

newSample = Math.Tanh(oldSample);
Image
or keep it unaffected from -0.5 to +0.5 and stitch that up with tanh if it goes beyond:

Code: Select all

if (oldSample > 0.5)
then newSample = 0.5 + 2 * Math.Tanh(2*(oldSample - 0.5));
else if (oldSample < 0.5)
then newSample = -0.5 + 2 * Math.Tanh(2*(oldSample + 0.5));
else newSample = oldSample;
Bitcrushing is easy. This one makes it sound like 10bits

Code: Select all

steps = 2^10;
...
newSample = Math.Round(oldSample * steps, 0) / steps;
assuming your samples are in the +1.0 to -1.0 range ofcourse...
Can probably be optimise by doing an AND operation with bitmasks which makes the less significant bits zero.
Last edited by BertKoor on Fri Nov 29, 2013 12:41 pm, edited 1 time in total.
We are the KVR collective. Resistance is futile. You will be assimilated. Image
My MusicCalc is served over https!!

Post

Whut?
:scared:
I'm tired of being insane. I'm going outsane for some fresh air.

Post

TheTurner wrote:
Sendy wrote:Digital by default sounds horrible. It's only thanks to years and years of research and refinement that digital synths sound good today.
100% correct , it does sound horrible i learnt that much allready.
My experience is that about 80% of what sounds horrible comes down to aliasing. Not necessarily direct aliasing as such, but still the failure to deal with a finite sampling rate adequately... so if you want to sound non-horrible, start learning about aliasing. ;)

Then about 10% comes down to the fact that you really shouldn't pretend that you can chop off short segments of an infinite signal and process them independently in the spectral domain. Then again analog can't do it at all (and streaming stuff from the interweb is kinda convenient too), so let's ignore that, because the final 10% is where everyone (and yeah, I do it too) optimizes on the basis of "nobody's going to hear any difference."

Anyway.. the tanh() thing mentioned is a workable "soft-clipper" but like all things digital will suffer from some aliasing, so oversampling would be a good idea. For a "limiter" though, what you typically want to do is detect the peaks of the signal, then temporarily lower the volume and raise it "slowly" back to whatever it was. If you manage to do it in a suitably subtle way, nobody's going to hear any difference. ;)

Post

mystran wrote:For a "limiter" though, what you typically want to do is detect the peaks of the signal, then temporarily lower the volume and raise it "slowly" back to whatever it was. If you manage to do it in a suitably subtle way, nobody's going to hear any difference. ;)
Now I know I'm not alone..... ;) :hihi:

Post

you can option for emulative bitcrushing, eg. identify the sample format of the device you wish to emulate and rewrite the sample accordingly. you'll notice that .wav format has been historically implemented several ways, which would result in microscopic changes in the signal. ultimately it will "all sound pretty much the same" as arbitrarily quantising the sample.
you come and go, you come and go. amitabha neither a follower nor a leader be tagore "where roads are made i lose my way" where there is certainty, consideration is absent.

Post

TheTurner wrote: here goes dont kill me ..


(double)yoursample=therealsample;
if (yoursample>32767.0)yoursample-=(yoursample/2);
if (yoursample<-32767.0)yoursample+=(yoursample/2);
therealsample=yoursample;


crude yep , agreed but works.
Sorry, going to have to kill you. That DOESN'T work. (At least if by "work" we mean act as a compressor/limiter.) It would make a horrible, clipping-like distortion. That's about it.

Post

thecontrolcentre wrote: and it's noob, not nub. :P
Now THAT'S a noob!

Post

TheTurner wrote:i know mate im not as thick as i seem , i know a limiter limits , crusher i didnt know though , never knew it changed the bitrate thats good info , if we keep up like this i wont look as stupid in ten years eh lol

and thanks for the info btw i know your trying to help.

so supposing i did something like

sambuffer[idontknow lets make it 1024*4 yeah]
sambuffer[offset++]=sample;
sambuffer[offset++]=sample;

so reduces it to half speed then if i mix the buffer the samples going to have a sample playing lower mixed with the origional , is that what you meen by bitrate?
That's sample rate. It's bit DEPTH that a "bitcrusher" changes. (i.e. How many possible values can a sample have? How many "bits per sample".) When you said "crusher" I assumed you meant compressor, as you also mentioned limiter. Bitcrushers have nothing to do with limiters, but compressors do, so I thought it was a safe assumption.

Bit RATE is the bit depth (in bits) times the sample rate (in samples per second).

Post

TheTurner wrote:
Sendy wrote:Digital by default sounds horrible. It's only thanks to years and years of research and refinement that digital synths sound good today.
100% correct , it does sound horrible i learnt that much allready.
We spin a lot of vinyl, do we?

Post Reply

Return to “DSP and Plugin Development”