Re: [LAD] Wave shapes & forms

From: Philippe Coatmeur <philcm@email-addr-hidden>
Date: Tue Oct 21 2014 - 17:31:01 EEST

On 21/10/14 15:26, David Olofson wrote:
> Really inefficient and awful sounding version:
> output[pos] = (sin (self->phase * 2 * PI ) >= 0 ? 1 : -1) * volume;
>
> Dirty trick: Round the phase increment so that the period becomes an
> integer number of sample frames! This produces crystal clear square
> waves, but frequency resolution is awful for high frequencies and/or
> low sample rates, of course.
>
> The simplest "correct" way is to construct the square wave by adding
> up partials (sines), and just stop below Nyqvist, which essentially
> brickwall-filters the waveform. Perfect results, but pretty
> expensive...
>
> The proper answer is that it's actually really complicated to do this
> well, because an ideal geometric waveform contains an infinite number
> of partials, and the ones above Nyqvist (sample rate / 2) will be
> mirrored down below Nyqvist, making it all sound awful.
>
> Some keywords: band limited oscillator, BLIT, BLEP, minBLEP
>
> You may find interesting code examples here: http://musicdsp.org/
>
> On Tue, Oct 21, 2014 at 3:56 PM, Philippe Coatmeur <philcm@email-addr-hidden> wrote:

Wow, that was quick. This (and Harry's infos) is exactly what I need,
thanks a lot LADs.

--Phil
>> Hi
>>
>> If this
>>
>> // calculate the next sample: phase ranges from 0 -> 1, but sin()
>> // expects its input in radians. Just multiply by 2 PI to convert it!
>> // We also multiply by volume so its not extremely loud.
>> output[pos] = sin( self->phase * 2 * PI ) * volume;
>>
>> Sends a sine wave to output (this is the standard sin math function, right?)
>> then what would send a square wave? What would send noise?
>>
>> Thanks -Phil
>>
>> --
>> Philippe "xaccrocheur" Coatmeur
>> http://bitbucket.org/xaccrocheur / https://github.com/xaccrocheur
>> http://opensimo.org/play/
>>
>>
>> _______________________________________________
>> Linux-audio-dev mailing list
>> Linux-audio-dev@email-addr-hidden
>> http://lists.linuxaudio.org/listinfo/linux-audio-dev
>>
>
>

-- 
Philippe "xaccrocheur" Coatmeur
http://bitbucket.org/xaccrocheur / https://github.com/xaccrocheur
http://opensimo.org/play/
_______________________________________________
Linux-audio-dev mailing list
Linux-audio-dev@email-addr-hidden
http://lists.linuxaudio.org/listinfo/linux-audio-dev
Received on Tue Oct 21 20:15:02 2014

This archive was generated by hypermail 2.1.8 : Tue Oct 21 2014 - 20:15:02 EEST