Page 1 of 1

Sinewave sound

Posted: Sat Mar 09, 2019 11:10 am
by ewan
Hi there,
I have recently started with devkitARM for NDS and I have been working with square waves using the soundPlayPSG function . I have been searching for a function to generate sine waves before I attempt to write one myself (instead of reinventing the wheel). I understand that from a hardware sense the PSG is Square Wave, but I am thinking that there must be ways to manipulate this.

Thanks in advance.

Re: Sinewave sound

Posted: Sun Mar 10, 2019 11:56 pm
by WinterMute
The PSG generates square waves, you can't make it generate sine waves, sorry.

Re: Sinewave sound

Posted: Mon Mar 11, 2019 10:10 am
by sverx
if you can change volumes quick enough you might generate something that resembles a PCM. :roll:

Re: Sinewave sound

Posted: Mon Mar 11, 2019 11:18 am
by ewan
Thanks WinterMute and sverx.

The idea of changing volumes is a good one. I have the Korg DS-10, and it got me wondering how did they do that? I guess they could have also used samples, but I want to stay clear of samples.

I'm starting to read your libnds sound.c WinterMute to get my head around what the DS can and can't do as I am new to this system :)

Re: Sinewave sound

Posted: Mon Mar 11, 2019 5:08 pm
by fincs
You don't actually need to change volumes quickly; because DS sound channels already support playing back PCM samples.

Re: Sinewave sound

Posted: Mon Mar 11, 2019 5:11 pm
by WinterMute
Is there a good reason to avoid samples? They can easily be generated on the fly - it's much easier than modulating PSG volume.

Pretty sure the Korg DS-10 uses samples.

Re: Sinewave sound

Posted: Tue Mar 12, 2019 11:49 am
by sverx
IMHO I wouldn't use the PSG at all, given the hardware can do much more than square waves, but if you really don't want to use the samples it's up to you :?

Re: Sinewave sound

Posted: Fri Mar 15, 2019 9:13 am
by ewan
Thanks guys,

You have got me thinking, I could generate some PCM data and stream it. I will read up on this now as I wish to build a very basic synthesiser with, for example Sine, Square, Triangle waves and ADSR. Thanks

Re: Sinewave sound

Posted: Sat Mar 16, 2019 12:07 am
by WinterMute
Maxmod can do streaming, see https://github.com/devkitPro/nds-exampl ... /streaming which should also be in your /opt/devkitpro/examples/nds directory.

There is more documentation at https://maxmod.devkitpro.org/

Re: Sinewave sound

Posted: Mon Mar 18, 2019 11:17 am
by ewan
Thanks WinterMute

That is excellent material and will really help me get on track!