2 eurocents question about AY-8912 possibilities

Probably the most technical forum around. It does not have to be coding related, or assembly code only. Just talk about how you can use the AY chip to do cool sounding things :)
User avatar
jbperin
Flight Lieutenant
Posts: 480
Joined: Wed Nov 06, 2019 11:00 am
Location: Valence, France

Re:

Post by jbperin »

Dbug wrote: Sun Nov 04, 2007 11:31 pm I packaged in a OSDK compliant the code of the "Welcome" from my Oric Mega Demo of 1997:

http://www.defence-force.org/ftp/forum/ ... lSound.zip
Thank you for sharing. It's a very interesting and instructive code snippet.
Dbug wrote: Sun Nov 04, 2007 11:31 pm (I'm using the old tables from the Atari ST ST-Replay software)
Have you ever tested the tables provided in the link by JamesD ?
http://map.tni.nl/articles/psg_sample.php#8bitsamples

They look better shaped than the ones provided in your DigitalSound
And I wonder if it could enhance the sound quality.

when i draw the function

Code: Select all

y = conv(tab1[x]) + conv(tab2[x]) + conv(tab3[x]) 
with 
conv(x) = 2^-((15-x)/2)
with msx replay tables, i get :
msx_replay.png
and with your atari replay tables, i get:
atari_replay.png
Dbug wrote: Tue Nov 06, 2007 8:51 pm You probably noticed the 7 "nop" instructions, it's to slow down the replay.
I also wonder if it could enhance the sound quality to spread the nop along the loop content, multiplexed with register writing rather then gather them at the end of the loop content.

What do you think ?
User avatar
jbperin
Flight Lieutenant
Posts: 480
Joined: Wed Nov 06, 2019 11:00 am
Location: Valence, France

Re: 2 eurocents question about AY-8912 possibilities

Post by jbperin »

I made a quick build of 4 various version of the sample player function.
DIGIT.tap
(12.52 KiB) Downloaded 187 times
On oricutron I find the best sounding version is number 2

Which one do people prefer on real hardware ?
User avatar
Dbug
Site Admin
Posts: 4437
Joined: Fri Jan 06, 2006 10:00 pm
Location: Oslo, Norway
Contact:

Re: 2 eurocents question about AY-8912 possibilities

Post by Dbug »

jbperin wrote: Thu Apr 15, 2021 7:06 pm I also wonder if it could enhance the sound quality to spread the nop along the loop content, multiplexed with register writing rather then gather them at the end of the loop content.
What do you think ?
On msx they did exactly that, using some Viterbi encoding.
https://www.msx.org/forum/development/m ... s-poor-psg

Basically the idea is that on the Atari ST, it's so fast to change registers that basically you can consider that writing to channels A, B and C is almost happening at the same time, while on the Oric it's so slow, that ideally the values for A, B and C should take into consideration the temporal delay.
User avatar
jbperin
Flight Lieutenant
Posts: 480
Joined: Wed Nov 06, 2019 11:00 am
Location: Valence, France

Re: 2 eurocents question about AY-8912 possibilities

Post by jbperin »

Dbug wrote: Thu Apr 15, 2021 8:36 pm On msx they did exactly that, using some Viterbi encoding.
https://www.msx.org/forum/development/m ... s-poor-psg
That's truly fascinating ..

What an interesting approach !!

Do we have the same on Oric ?
User avatar
Dbug
Site Admin
Posts: 4437
Joined: Fri Jan 06, 2006 10:00 pm
Location: Oslo, Norway
Contact:

Re: 2 eurocents question about AY-8912 possibilities

Post by Dbug »

I had plans, but did not really act on it, so feel free to experiment :)

My idea was to find an encoding to basically generate a series to write on A, B, C, A, B, C, A, B, C, ... computing the best combination of values to write to generate a 8 bit quality sample by just changing the volume value, so basically 4 bit encoding, two values per byte, but high quality, but did not have the time.
User avatar
jbperin
Flight Lieutenant
Posts: 480
Joined: Wed Nov 06, 2019 11:00 am
Location: Valence, France

Re: 2 eurocents question about AY-8912 possibilities

Post by jbperin »

Dbug wrote: Fri Apr 16, 2021 2:29 pm feel free to experiment :)
You should not say things like that to someone who is struggling to find the courage to finish a game.
That is not kind of you.
Dbug wrote: Fri Apr 16, 2021 2:29 pm My idea was to find an encoding to basically generate a series to write on A, B, C, A, B, C, A, B, C, ... computing the best combination of values to write to generate a 8 bit quality sample by just changing the volume value, so basically 4 bit encoding, two values per byte, but high quality, but did not have the time.
Well, it sounds good .. but I wonder if there could be a more efficient approach by considering that we don't necessary have to cycle around A, B and C
Because, in the end, what's matter is the sum : conv(A)+conv(B)+conv(C) (with conv() being the reverse logarithmic scale thing)
The goal is to make this sum follows (as much as possible) the sampled signal.
It may happen that, for some reason, the best way to follow the signal is to only make one or two channel change rather than systematically update all three channels.

In such a perspective, the encoding would consist in finding a sequence of couple (channel, value) .
A, 2, B, 3, B, 4, B, 5, A, 3, etc .. ect ..

And the player loop would look like:

Code: Select all

#define VIA_1	$30f
#define VIA_2	$30c

#define LATCH_REG_NUMBER  sta VIA_1:lda #$EE:sta VIA_2:stx VIA_2
#define LATCH_REG_VALUE  sta VIA_1:lda #$EC:sta	VIA_2:stx VIA_2

playnote_loop

    
   ;; ... read sample whatever way 
adr_samp
	lda	_Sample

    ;; insert here code get channel register in register A
    sta reg_number + 1
    ;; insert here code to get channel value in register A
    sta reg_value + 1
    
reg_number
	lda	#0: LATCH_REG_NUMBER
reg_value
	lda	#0: LATCH_REG_VALUE

	inc	adr_samp+1
	bne	playnote_loop

	inc	adr_samp+2
	dec	_Counter
	bne	playnote_loop
Only one channel amplitude register writing in the loop in order to make sure that changes of output level (A+B+C) occur on an hyper periodic basis.

It could even be possible to use some NOP to help making sure that the loop content is always the same duration and does not depend on branching condition.

The goal here would be that the writing in amplitude register are made hyper regularly .. Regularity is more important than speed for sound fidelity.
User avatar
Dbug
Site Admin
Posts: 4437
Joined: Fri Jan 06, 2006 10:00 pm
Location: Oslo, Norway
Contact:

Re: 2 eurocents question about AY-8912 possibilities

Post by Dbug »

Well, the problem with the nop method of synchronisation is basically you can only do things like my "Welcome", which does some sound but you can't do anything else during that time (or the only you can do is to run something that takes a fixed amount of time).

What you want is something that ideally would run from the IRQ, which obviously comes with its own set of challenges (that's what I did in NyAtmos and OricTech).

The idea of doing ABCABCABC.. was to not lose any room to encode information about which register to update, but obviously that only work if you can get a data generator able to compute a lot of combinations of permutations to see if it's possible to do something close enough to the original signal just by changing fixed values, but yeah, there are many possible ways of doing that.

Another thing to investigate is also the Tivoli pirat method, which just uses 2 bit samples, and achieve good quality by using a higher frequency replay.

See: https://forum.defence-force.org/viewtop ... oli#p16219
User avatar
jbperin
Flight Lieutenant
Posts: 480
Joined: Wed Nov 06, 2019 11:00 am
Location: Valence, France

Re: 2 eurocents question about AY-8912 possibilities

Post by jbperin »

Dbug wrote: Fri Apr 16, 2021 5:30 pm that's what I did in NyAtmos and OricTech


waou !! :shock:

How the hell is that possible to play sampled music on interrupt (100Hz) ?

That's not PCM.

Is it possible to see the source code of this magic ?
User avatar
jbperin
Flight Lieutenant
Posts: 480
Joined: Wed Nov 06, 2019 11:00 am
Location: Valence, France

Re: 2 eurocents question about AY-8912 possibilities

Post by jbperin »

jbperin wrote: Fri Apr 16, 2021 6:01 pm
Is it possible to see the source code of this magic ?
Yes .. I realize it is already on my hard drive LOL !!! :D
Post Reply