Nub and im not joking.
-
- KVRer
- 3 posts since 29 Nov, 2013
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?.
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.
-
thecontrolcentre thecontrolcentre https://www.kvraudio.com/forum/memberlist.php?mode=viewprofile&u=76240
- KVRAF
- 37262 posts since 27 Jul, 2005 from Scottish Borders
-
- KVRer
- Topic Starter
- 3 posts since 29 Nov, 2013
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?
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.
- KVRAF
- 5223 posts since 20 Jul, 2010
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!
-
- KVRer
- Topic Starter
- 3 posts since 29 Nov, 2013
100% correct , it does sound horrible i learnt that much allready.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.
-
thecontrolcentre thecontrolcentre https://www.kvraudio.com/forum/memberlist.php?mode=viewprofile&u=76240
- KVRAF
- 37262 posts since 27 Jul, 2005 from Scottish Borders
- KVRAF
- 16823 posts since 8 Mar, 2005 from Utrecht, Holland
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.
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:
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:

or keep it unaffected from -0.5 to +0.5 and stitch that up with tanh if it goes beyond:
Bitcrushing is easy. This one makes it sound like 10bits
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.
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.TheTurner wrote:Code: Select all
(double)yoursample=therealsample; if (yoursample>32767.0)yoursample-=(yoursample/2); if (yoursample<-32767.0)yoursample+=(yoursample/2); therealsample=yoursample;
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;Code: Select all
newSample = Math.Tanh(oldSample);
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;Code: Select all
steps = 2^10;
...
newSample = Math.Round(oldSample * steps, 0) / steps;
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. 
My MusicCalc is served over https!!
My MusicCalc is served over https!!
- KVRAF
- 2040 posts since 15 Aug, 2012 from Australia
Whut?

I'm tired of being insane. I'm going outsane for some fresh air.
- KVRAF
- 8484 posts since 12 Feb, 2006 from Helsinki, Finland
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.TheTurner wrote:100% correct , it does sound horrible i learnt that much allready.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.
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.
-
- KVRist
- 205 posts since 12 Feb, 2009 from Perú
Now I know I'm not alone.....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.
-
- Banned
- 12367 posts since 30 Apr, 2002 from i might peeramid
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.
-
AdmiralQuality AdmiralQuality https://www.kvraudio.com/forum/memberlist.php?mode=viewprofile&u=83902
- Banned
- 6657 posts since 10 Oct, 2005 from Toronto, Canada
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.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.
-
AdmiralQuality AdmiralQuality https://www.kvraudio.com/forum/memberlist.php?mode=viewprofile&u=83902
- Banned
- 6657 posts since 10 Oct, 2005 from Toronto, Canada
-
AdmiralQuality AdmiralQuality https://www.kvraudio.com/forum/memberlist.php?mode=viewprofile&u=83902
- Banned
- 6657 posts since 10 Oct, 2005 from Toronto, Canada
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.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?
Bit RATE is the bit depth (in bits) times the sample rate (in samples per second).
-
AdmiralQuality AdmiralQuality https://www.kvraudio.com/forum/memberlist.php?mode=viewprofile&u=83902
- Banned
- 6657 posts since 10 Oct, 2005 from Toronto, Canada
We spin a lot of vinyl, do we?TheTurner wrote:100% correct , it does sound horrible i learnt that much allready.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.

