Sinewave sound

Post Reply
ewan
Posts: 4
Joined: Sat Mar 09, 2019 10:53 am

Sinewave sound

Post by ewan » Sat Mar 09, 2019 11:10 am

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.

WinterMute
Site Admin
Posts: 1986
Joined: Tue Aug 09, 2005 3:21 am
Location: UK
Contact:

Re: Sinewave sound

Post by WinterMute » Sun Mar 10, 2019 11:56 pm

The PSG generates square waves, you can't make it generate sine waves, sorry.
Help keep devkitPro toolchains free, Donate today

Personal Blog

sverx
Posts: 94
Joined: Wed Aug 12, 2009 2:56 pm
Location: github.com/sverx
Contact:

Re: Sinewave sound

Post by sverx » Mon Mar 11, 2019 10:10 am

if you can change volumes quick enough you might generate something that resembles a PCM. :roll:

ewan
Posts: 4
Joined: Sat Mar 09, 2019 10:53 am

Re: Sinewave sound

Post by ewan » Mon Mar 11, 2019 11:18 am

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 :)

User avatar
fincs
( ͡° ͜ʖ ͡°)
Posts: 103
Joined: Mon Jul 12, 2010 9:45 pm
Location: Seville, Spain
Contact:

Re: Sinewave sound

Post by fincs » Mon Mar 11, 2019 5:08 pm

You don't actually need to change volumes quickly; because DS sound channels already support playing back PCM samples.
Donate to devkitPro - help us stay alive!

WinterMute
Site Admin
Posts: 1986
Joined: Tue Aug 09, 2005 3:21 am
Location: UK
Contact:

Re: Sinewave sound

Post by WinterMute » Mon Mar 11, 2019 5:11 pm

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.
Help keep devkitPro toolchains free, Donate today

Personal Blog

sverx
Posts: 94
Joined: Wed Aug 12, 2009 2:56 pm
Location: github.com/sverx
Contact:

Re: Sinewave sound

Post by sverx » Tue Mar 12, 2019 11:49 am

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 :?

ewan
Posts: 4
Joined: Sat Mar 09, 2019 10:53 am

Re: Sinewave sound

Post by ewan » Fri Mar 15, 2019 9:13 am

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

WinterMute
Site Admin
Posts: 1986
Joined: Tue Aug 09, 2005 3:21 am
Location: UK
Contact:

Re: Sinewave sound

Post by WinterMute » Sat Mar 16, 2019 12:07 am

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/
Help keep devkitPro toolchains free, Donate today

Personal Blog

ewan
Posts: 4
Joined: Sat Mar 09, 2019 10:53 am

Re: Sinewave sound

Post by ewan » Mon Mar 18, 2019 11:17 am

Thanks WinterMute

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

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 4 guests