Jump to content
IGNORED

PSG2BAS utility to convert music/sounds


nanochess

Recommended Posts

Hi everyone.

 

Some months ago I've released my CoolCV emulator with capability to log PSG sounds value using Ctrl+F9 (or Ctrl-Fn-F9 in Mac)

 

This data is put into a psg.txt file and then you can cut the interesting block into another file.

 

AND THEN pass this extracted file into psg2bas, an utility I've wrote to convert this data into compressed playable music by IntyBASIC ;)

 

It works very well :grin:. Currently it cannot handle the noise channel but scarce Colecovision games use it.

 

Included executables for Windows and Mac.

 

Edit: v0.1 allows to ignore channels, useful if logged music includes sound effects.

 

Enjoy it!

psg2bas.zip

psg2bas_v0.1.zip

  • Like 4
Link to comment
Share on other sites

Hi everyone.

 

Some months ago I've released my CoolCV emulator with capability to log PSG sounds value using Ctrl+F9 (or Ctrl-Fn-F9 in Mac)

 

This data is put into a psg.txt file and then you can cut the interesting block into another file.

 

AND THEN pass this extracted file into psg2bas, an utility I've wrote to convert this data into compressed playable music by IntyBASIC ;)

 

It works very well :grin:. Currently it cannot handle the noise channel but scarce Colecovision games use it.

 

Included executables for Windows and Mac.

 

Enjoy it!

Works awesome, now I can throw away my ugly version. Thanks

  • Like 1
Link to comment
Share on other sites

BTW, this doesn't MIX with the IntyBASIC tracker.

 

If you need to play sound with this code and you've enabled before the IntyBASIC tracker you should use this:

 

     PLAY NONE
     SOUND 0,,0
     SOUND 1,,0
     SOUND 2,,0
Before enabling this mini-tracker, and when you're finished (if you want to use again the internal IntyBASIC tracker), you should do:

 

     PLAY SIMPLE     ' Or PLAY FULL if you like
Link to comment
Share on other sites

As always, thanks for sharing the awesomeness!

I cracked open the psg2bas.bas file and saw this:

' Just to allow to TV synchro start successfully
FOR c = 0 TO 60: WAIT: NEXT c


I have not seen that before. Should that be a standard initialization routine for IntyBASIC stuff these days?


Thanks.


Hi everyone.

Some months ago I've released my CoolCV emulator with capability to log PSG sounds value using Ctrl+F9 (or Ctrl-Fn-F9 in Mac)

This data is put into a psg.txt file and then you can cut the interesting block into another file.

AND THEN pass this extracted file into psg2bas, an utility I've wrote to convert this data into compressed playable music by IntyBASIC ;)

It works very well :grin:. Currently it cannot handle the noise channel but scarce Colecovision games use it.

Included executables for Windows and Mac.

Enjoy it!

Link to comment
Share on other sites

Does it make any sense for me to add a similar logging facility to jzIntv? Right now, you can watch the PSG with the 'w' command in the debugger.

 

Granted, the sound chip in the ColecoVision is rather different than the AY-3-891x, so ironically you'd need a different converter to handle the fact you're converting from AY-3-8914 to AY-3-8914. LOL

Link to comment
Share on other sites

How cool! It is translating the SN76489A to AY8910 registers. Well done!

AY8910 has a wider range of frequencies so conversion can be always 1:1.

 

The two chips differ in the way noise is generated and added to channels, it won't be easy to support it.

 

PS

about sfx and intellevision, the editor here allows to design sfx on AY8910 (on a single channel)

 

https://shiru.untergrund.net/files/ayfxedit.zip

 

and you can export the PSG registers as CSV file.

Naturally if you need them in Intybasic you need to code your own converter and player

Edited by artrag
Link to comment
Share on other sites

I cracked open the psg2bas.bas file and saw this:

 

' Just to allow to TV synchro start successfully
FOR c = 0 TO 60: WAIT: NEXT c

I have not seen that before. Should that be a standard initialization routine for IntyBASIC stuff these days?

 

I've done this because when you turn on an Intellivision, the TV set takes a few moments to recognize the synchronization.

 

In this first second you'll not hear any sound or music.

 

Does it make any sense for me to add a similar logging facility to jzIntv? Right now, you can watch the PSG with the 'w' command in the debugger.

 

Granted, the sound chip in the ColecoVision is rather different than the AY-3-891x, so ironically you'd need a different converter to handle the fact you're converting from AY-3-8914 to AY-3-8914. LOL

I would be very interesting to have a log feature.

 

Because this way we could learn of how are done sound effects without having to go into the EXEC ROM.

 

Didn't thought on this but I suggest the format for each row could read like this:

 

A=xxxx xx B=xxxx xx C=xxxx xx E=xxxx xx M=xx Frame:x
I think this is easy to read for a human being and also easily processable by an automated tool.

 

How cool! It is translating the SN76489A to AY8910 registers. Well done!

AY8910 has a wider range of frequencies so conversion can be always 1:1.

 

The two chips differ in the way noise is generated and added to channels, it won't be easy to support it.

 

PS

about sfx and intellevision, the editor here allows to design sfx on AY8910 (on a single channel)

 

https://shiru.untergrund.net/files/ayfxedit.zip

 

and you can export the PSG registers as CSV file.

Naturally if you need them in Intybasic you need to code your own converter and player

Thanks! I'll give a look.

 

The SN76489 is able to generate lower frequencies for noise, but anyway the LFSR sounds completely different.

Link to comment
Share on other sites

The noise generator in the SN76489 has independent volume control (in the AY8910 it gets the volume of the channel used to mix it) and 4 frequency settings:

fn = 3,57MHz/512

fn = 3,57MHz/1024

fn = 3,57MHz/2048

fn = frequency from channel 3
Usually when used with frequency from channel 3 this latter is muted.
In the AY8910 the noise generator has 5 bits to define the chip rate
fn = 3,57MHz/(16*(1+Tn))
In this way the lowest frequency for noise bandwidth is fn = 3,57MHz/(16*32) = fn = 3,57MHz/512 matchs the first mode in the SN76489
Anyway there is no mean in AY8910 to mix noise with tones using independent volumes and without disturbing one tone channel.
In the AY8910 noise is always XORed to a tone channel, in this way the noise is displaced in frequency around the channel frequency and they get the same volume.
Willing to have pure noise one should set one channel with period = 0 and use its volume to approximate the attenuation in the SN76489...
Edited by artrag
  • Like 2
Link to comment
Share on other sites

In the AY8910 noise is always XORed to a tone channel, in this way the noise is displaced in frequency around the channel frequency and they get the same volume.

 

My understanding is that the noise is "AND"ed to a tone channel. At least that is what Joe Z. has documented. I believe this was also empirically verified. I don't know either way, so I'm curious to find out which is correct.

 

-dZ.

Link to comment
Share on other sites

There are 2 enable bits for each channel. One enables pure tone and the other enables noise.

 

You can have pure noise disabling the pure tone and enabling noise.

 

The mix works like an AND gate (as DZ-Jay pointed correctly) so the noise is mixed with tone if both are enabled.

  • Like 1
Link to comment
Share on other sites

Sure, it is an 'and', not a 'xor' .

'And' is equivalent to a analog product, so, 'anding' by a square wave is almost equivalent to a frequency displacement.

Xor is almost an analog addition

 

Agreed. The "AND" gives you at least some level of control over the pitch of the noise.

 

For completeness, below is the actual mixing results, as documented in the SDK-1600:

    Within each channel, tone and noise are mixed as follows:

        output_A = ( tone_A OR tone_en_A ) AND ( noise_gen AND noise_en_A )
        output_B = ( tone_B OR tone_en_B ) AND ( noise_gen AND noise_en_B )
        output_C = ( tone_C OR tone_en_C ) AND ( noise_gen AND noise_en_C )
 

artrag's point remains: You cannot individually control the noise or tone volume balance on a channel, they are ANDed together and then the resulting signal is attenuated as necessary.

 

The only way to get an independent "noise channel" is to dedicate one to it, by disabling the "tone enable" bit. Obviously, this leaves you only two more channels for tones.

 

I understood that he was trying to contrast this to other sound chips (like the SN76489), which have 3 tone generators and one noise generator, all independently controlled. The C=64 SID is similar (as I remember it). The PSG, on the other hand says it has three tone generators and one noise generator, but the noise generator does not get its own dedicated channel. This affects translating sound effects from one chip to another.

 

-dZ.

Edited by DZ-Jay
Link to comment
Share on other sites

It occurs to me that one thing IntyBASIC could provide is a sound generation "scripting engine." It doesn't have to be very fancy, just a set of commands that run on their own sub-process that alter the shape of the sound. It should include simple commands to manipulate the PSG, and some "program-flow" commands to allow loops, counters, timed events, etc.

 

I believe the EXEC includes something like this, which is what facilitated cool sound effects like the "splash" sound in Thin Ice, or the "crowd cheer" in sports games.

 

I think something like this could allow new and veteran programmers to be very creative. It's sort of the same they do today already, but letting IntyBASIC take care of the inner piping, rather than having to add all sorts of overhead to their game logic code.

 

-dZ.

Link to comment
Share on other sites

Pt3 by Shiru Otaku - Angel 2 (not a true pt3 player, it is more a log player )

 

Wow, that sounds awesome! The drums could use some work (they are a bit muddled and "noisy," especially the cymbals and snare), but the instruments are brilliant!

 

By the end, it even sounds like you're running a filter sweep over the bass. How do you do that, is that with noise modulation on the tone? That effect sounds awesome to me. :thumbsup:

 

 

 

Another test with pt3 music

 

This one is hard to hear. The tone is very low volume, and there is a noise crack, which I imagine should be part of the drums, but make it sound like there's line distortion. The music itself comes out fine, but the volume is not good.

 

By the way, I'm interested to know the data format of this tracker. Is it just PSG register dump?

 

-dZ.

Link to comment
Share on other sites

There is something wrong in the data. I'll post a fix asap.

Dz it is almost a log player, but I'm working to reduce redundant sequences...

 

I imagine that by "log player" you mean that it plays a log containing a dump of the PSG registers over time, right? Cool.

 

 

 

Pt3 by Shiru Otaku - Angel 2 (not a true pt3 player, it is more a log player )

[edit] Now with a small fix in the noise data

 

What are we testing here? It looks (and sounds) like the Inty-B intro created by Tarzilla.

 

 

 

Small fix in the noise data, new roms are in the previous posts

For your fun, player and sample data added

 

We're missing the rom to "pt3.rom" above, which in my opinion was the coolest tune. :)

 

By the way, it occurs to me that these tracks sound very close to what can be accomplished with Arnauld's Intellivision Tracker. It plays modules described in something similar to Fast Tracker II XM format. It's not a register dump, but it gives you very granular control over the channels on every tracker tick.

 

I wonder if something like that could be incorporated into IntyBASIC...

 

-dZ.

Link to comment
Share on other sites

Maybe Tarzilla is Shiru, who knows. :)

Tonight I will post the original pt3 files so you can investigate

 

I don't know what you mean by that. What I was trying to say is that the "intro.rom" file is not a music player file like the others. It's the "intro.rom" file that comes with IntyBASIC SDK. Is that what you intended?

 

-dZ.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...