Digisound on PSG (YM2149)

GFA, ASM, STOS, ...

Moderators: simonsunnyboy, Mug UK, Zorro 2, Moderator Team

mrcoke
Retro freak
Retro freak
Posts: 11
Joined: Tue Jul 03, 2007 4:26 pm
Location: hamm, germany

Digisound on PSG (YM2149)

Postby mrcoke » Fri Mar 13, 2009 5:29 pm

Hi Folks!

Shame on me - ok. I really have no idea how to play an 8bit digisound sample on the PSG. All i found on the net is to combine all 3 PSG channels to reach a better sound than 4bit digisound on 1 channel. (Because the Volume Register of any channel is 4bit)

Well, i just want to understand the basics to be able to play digisound. I know already, that a digisound is definded by its resolution in bits and the replay rate in KHz. That's clear so far. But i don't know how to interprete the values of a digisound value - means: on a 8bit sample there are values like 0 (zero) that means silence - but there are positive and negative values up to 128 - ok, a greater value is a greater sound, but what is the difference between negative and positive values ?!??

If anybody knows - how to setup the PSG - and like to share this information -- please, help me.
signed off,
mr.coke

User avatar
Mug UK
Administrator
Administrator
Posts: 11422
Joined: Thu Apr 29, 2004 7:16 pm
Location: Stockport (UK)
Contact:

Re: Digisound on PSG (YM2149)

Postby Mug UK » Fri Mar 13, 2009 5:52 pm

Loads of code on this thread including sample playback - viewtopic.php?f=16&t=15021

More info on this page - viewtopic.php?f=68&t=15666
My main site: http://www.mug-uk.co.uk - slowly digging up the bits from my past (and re-working a few): Atari ST, Sega 8-bit (game hacks) and NDS (Music ripping guide).

I develop a free Word (for Windows) add-in that's available for Word 2007 upwards. It's a fix-it toolbox that will allow power Word users to fix document errors. You can find it at: http://www.mikestoolbox.co.uk

mrcoke
Retro freak
Retro freak
Posts: 11
Joined: Tue Jul 03, 2007 4:26 pm
Location: hamm, germany

Re: Digisound on PSG (YM2149)

Postby mrcoke » Fri Mar 13, 2009 6:49 pm

Muguk wrote:Loads of code on this thread including sample playback - viewtopic.php?f=16&t=15021

More info on this page - viewtopic.php?f=68&t=15666


Hi Muguk...
Thanks a lot for your reply...
The "Playing MODs and multi samples" thread i found already. This thread don't answer my questions, cause i don't want to mix multiple samples.
The "playsam.zip" source in the "Ronalds A. Sources will appear here! Alot!!" thread is still interesting for me, but this is just a code snippet -- please don't understand me ... i don't want to rip a code snippet - i simply want to understand how that stuff works.

however, thank you for the hints...
i'm just seraching... Yellow_Colorz_PDT_19

mr.coke

User avatar
Mug UK
Administrator
Administrator
Posts: 11422
Joined: Thu Apr 29, 2004 7:16 pm
Location: Stockport (UK)
Contact:

Re: Digisound on PSG (YM2149)

Postby Mug UK » Fri Mar 13, 2009 9:18 pm

No probs .. just did a quick search on 'samples' and linked to the ones I thought might be useful. There's plenty of old school coders on here who might be able to help you though ;-)
My main site: http://www.mug-uk.co.uk - slowly digging up the bits from my past (and re-working a few): Atari ST, Sega 8-bit (game hacks) and NDS (Music ripping guide).

I develop a free Word (for Windows) add-in that's available for Word 2007 upwards. It's a fix-it toolbox that will allow power Word users to fix document errors. You can find it at: http://www.mikestoolbox.co.uk

User avatar
oberje
Atari freak
Atari freak
Posts: 58
Joined: Sat Jan 10, 2009 2:38 pm
Location: Sussex, UK
Contact:

Re: Digisound on PSG (YM2149)

Postby oberje » Fri Mar 13, 2009 11:07 pm

mrcoke wrote:Well, i just want to understand the basics to be able to play digisound. I know already, that a digisound is definded by its resolution in bits and the replay rate in KHz. That's clear so far. But i don't know how to interprete the values of a digisound value - means: on a 8bit sample there are values like 0 (zero) that means silence - but there are positive and negative values up to 128 - ok, a greater value is a greater sound, but what is the difference between negative and positive values ?!??

There's no real difference in signed/unsigned, it's just a convention, ultimately to be played on the PSG the value is always translated to a positive ( or 0 ) volume ( obtained by setting various combinations of the 4 bit volumes for the 3 channels ).

Aside: 0 can be silence, but note, any value will be silent if it is continuous and unchanging. It's the change in volume & the frequencies that makes the sound.

Cheers,
oberje

mrcoke
Retro freak
Retro freak
Posts: 11
Joined: Tue Jul 03, 2007 4:26 pm
Location: hamm, germany

Re: Digisound on PSG (YM2149)

Postby mrcoke » Sun Mar 15, 2009 7:44 am

oberje wrote:There's no real difference in signed/unsigned, it's just a convention, ultimately to be played on the PSG the value is always translated to a positive ( or 0 ) volume ( obtained by setting various combinations of the 4 bit volumes for the 3 channels ).

Aside: 0 can be silence, but note, any value will be silent if it is continuous and unchanging. It's the change in volume & the frequencies that makes the sound.

Cheers,
oberje


Ahh - ok ?! A few a good hints - thanks very much!

I still have a problem with the volume controlling. There are 3 channels with 4 bit volume, but i guess - a volume level 123 (ABC) is as loud as 321 (ABC) - so there are only 46 different volumes combining the 3 channels? Or is the trick to mix the volume with tone and/or noise - maybe a higher tone sounds louder than a lower tone? =)

mr.coke

User avatar
oberje
Atari freak
Atari freak
Posts: 58
Joined: Sat Jan 10, 2009 2:38 pm
Location: Sussex, UK
Contact:

Re: Digisound on PSG (YM2149)

Postby oberje » Sun Mar 15, 2009 8:07 am

mrcoke wrote:Ahh - ok ?! A few a good hints - thanks very much!
mr.coke


You might want to check out this link: http://map.grauw.nl/articles/psg_sample.php

Cheers,
oberje

User avatar
unseenmenace
Atari God
Atari God
Posts: 1961
Joined: Tue Sep 21, 2004 9:33 pm
Location: Margate, Kent, UK
Contact:

Re: Digisound on PSG (YM2149)

Postby unseenmenace » Sun Mar 15, 2009 10:38 am

Attached is a sample (unsigned I believe) to YM register lookup table and example code someone sent me, sorry I forget who :)
You do not have the required permissions to view the files attached to this post.
UNSEEN MENACE
Several STFM's, 4MB STE, 2MB TT with 1.2GB Hard Drive and 14MB Falcon with 540MB Hard Drive,
Lynx 2 and Jaguar with JagCD
Member of GamebaseST and AtariLegend team
Check out my website at http://unseenmenace.110mb.com

User avatar
bod/STAX
Atari Super Hero
Atari Super Hero
Posts: 508
Joined: Wed Nov 24, 2004 8:13 pm
Location: Halesowen, West Midlands, England

Re: Digisound on PSG (YM2149)

Postby bod/STAX » Thu Mar 19, 2009 6:43 pm

Sorry, I can never remember which is which when it comes to signed samples and unsigned samples.

But if you have a sample that contains the values -127 to +128 then you just add 128 ($80) to all the bytes
of the sample thus giving you values from 0 to 255. These values then can be an offset into a sound table
that contains all sound that can be played through the soundchip.

Click this link and scroll down to where I've uploaded the source code to the Lost Boys Megabang demo.
You'll see that it replays samples at various speeds using the above method (the sample already has 128 ($80)
added to it).

http://atari-forum.com/viewtopic.php?f=68&t=14794&p=127044&hilit=megabang#p127044
So let it be written, So let it be done. I'm sent here by the chosen one.

User avatar
Nyh
Atari God
Atari God
Posts: 1496
Joined: Tue Oct 12, 2004 2:25 pm
Location: Netherlands

Re: Digisound on PSG (YM2149)

Postby Nyh » Fri Mar 20, 2009 11:35 am

bod/STAX wrote:Sorry, I can never remember which is which when it comes to signed samples and unsigned samples.

But if you have a sample that contains the values -127 to +128 then you just add 128 ($80) to all the bytes
of the sample thus giving you values from 0 to 255. These values then can be an offset into a sound table
that contains all sound that can be played through the soundchip.

Click this link and scroll down to where I've uploaded the source code to the Lost Boys Megabang demo.
You'll see that it replays samples at various speeds using the above method (the sample already has 128 ($80)
added to it).

You can make signed form unsigned by flipping the MSB but you can also switch lower half and upper half from the sample look-up table converting the table from signed samples to unsigned samples and back.

Hans Wessels


Social Media

     

Return to “Coding”

Who is online

Users browsing this forum: No registered users and 1 guest