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
waskol
Flight Lieutenant
Posts: 414
Joined: Wed Jun 13, 2007 8:20 pm
Location: FRANCE, Paris

2 eurocents question about AY-8912 possibilities

Post by waskol »

Do you think it would be technically possible to play the raw data of a wav file with a ay-8912 ???
Of course, I imagine that the main limitation is the sample rate frequency...

what do you think ?
JamesD
Flight Lieutenant
Posts: 358
Joined: Tue Nov 07, 2006 7:38 am

Re: 2 eurocents question about AY-8912 possibilities

Post by JamesD »

waskol wrote:Do you think it would be technically possible to play the raw data of a wav file with a ay-8912 ???
Of course, I imagine that the main limitation is the sample rate frequency...

what do you think ?
Yes. It was common on the Atari ST.
User avatar
waskol
Flight Lieutenant
Posts: 414
Joined: Wed Jun 13, 2007 8:20 pm
Location: FRANCE, Paris

Post by waskol »

hmm, that is pretty interesting...
Therefore, I wonder if an Oric could play a wav file, or at least the raw data of a wav file...

I will try to see on the internet if I find something about how people realized it with an Atari ST :wink:
User avatar
waskol
Flight Lieutenant
Posts: 414
Joined: Wed Jun 13, 2007 8:20 pm
Location: FRANCE, Paris

Post by waskol »

hmmm, it seems that someone did it for spectrum :wink:
http://www.zxdemo.org/extra/src/samplepack-20070527.zip

the zip file contains nice piece of source code in order ti realize a wav player for a zx-spectrum (and for an Oric maybe ?) :P
User avatar
Dbug
Site Admin
Posts: 4437
Joined: Fri Jan 06, 2006 10:00 pm
Location: Oslo, Norway
Contact:

Post by Dbug »

Well, it's "trivial" to adapt to the Oric all the methods used on other AY/YM based machines.

I did my first 8 bit replay routine in 1997, for the "Oric Mega Demo" - mega only in the name -, making it replay the "Welcome" sample of the Barbarian 2 game "Welcome to the Dungeon of Drax: Please choose your warrior".

Performance wise, 8 bits is not very efficient, it's easier and way less CPU intensive to replay 4 bits samples. It also takes half the memory, since you can pack 2 samples on one byte.

The idea is just to play with the volume registers on the chanels. On one chanel you can get a value between 0 and 15 (0 to 1volt), and by using two or three chanels, you can get a larger value which increase the number of potential values and the volume (from 0 to 3 volts), giving a nearly 8 bit quality by using the cumulated 12 bits creatively.

I used the conversion tables from ST Replay, and they worked fine on the Oric as well.

Twilighte can provide good code for replaying samples. Mine is very crappy, I did that a very long time ago.
User avatar
Twilighte
Game master
Posts: 819
Joined: Sat Jan 07, 2006 12:07 am
Location: Luton, UK
Contact:

Post by Twilighte »

Thanks Dbug, Pure WAV files from the PC contain about 16 or 32 bytes of header info, which is not so cool at the start of a sample when played on the Oric.

Their are several ways to play samples on the Oric, some are faster than others but remember, the faster the routine the more memory the sample may use.
I have written sample players from 200Hz up to 44Khz.
If you need a routine, let me know and i'll see if i can find time to find one.
User avatar
waskol
Flight Lieutenant
Posts: 414
Joined: Wed Jun 13, 2007 8:20 pm
Location: FRANCE, Paris

Post by waskol »

The idea can be to remove the header and keep just the chunks (I mean, only the raw data, the wave form...).
For this we can assume a default sample rate, mono, 8 bits, and so forth :wink:
JamesD
Flight Lieutenant
Posts: 358
Joined: Tue Nov 07, 2006 7:38 am

Post by JamesD »

I found some decent info on an MSX page.
It has info on playing 8 bit samples and there is supposedly even a link to a read wave program to test it out.
http://map.tni.nl/articles/psg_sample.php#8bitsamples
User avatar
waskol
Flight Lieutenant
Posts: 414
Joined: Wed Jun 13, 2007 8:20 pm
Location: FRANCE, Paris

Post by waskol »

OK, let'see it in this way :
How could it be possible to "translate" some raw datas of a wav file into Oric asm code ???

If we can sort out an algorithm, it might be possible :
- to compose on PC
- "Translate" the resulting wav file into oric asm (on the PC)
- compile with OSDK
- hear the result on Oric ;)

I am pretty sure it is possible, but my skills in asm and moreover of how to address the AY-8912 are, hummm... well :lol:
User avatar
Dbug
Site Admin
Posts: 4437
Joined: Fri Jan 06, 2006 10:00 pm
Location: Oslo, Norway
Contact:

Post by Dbug »

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

- welcome.s is a 8bit sample saved in raw/unsigned format
- digit.s is the replay code, including three 256 bytes tables used to convert the 8 bit sample to a single 4 bits value for each separate chanel.

(I'm using the old tables from the Atari ST ST-Replay software)
User avatar
waskol
Flight Lieutenant
Posts: 414
Joined: Wed Jun 13, 2007 8:20 pm
Location: FRANCE, Paris

Post by waskol »

DBUG, I am afraid but... you are the best !!!!
It is really impressive.

This demo shows that it is possible to get anything out of the oric...
really impressive... (my jaw is still on the floor...)
User avatar
Dbug
Site Admin
Posts: 4437
Joined: Fri Jan 06, 2006 10:00 pm
Location: Oslo, Norway
Contact:

Post by Dbug »

waskol wrote:DBUG, I am afraid but... you are the best !!!!
It is really impressive.

This demo shows that it is possible to get anything out of the oric...
really impressive... (my jaw is still on the floor...)
Well, I only adapted what we did on the Atari ST (same sound chip).

And both Fabrice and Twilighte made sample sound, and there is this Rambo demo of the Tivoli Pirat as well, so please give the credits to other people :)
User avatar
waskol
Flight Lieutenant
Posts: 414
Joined: Wed Jun 13, 2007 8:20 pm
Location: FRANCE, Paris

Post by waskol »

Dbug wrote:
waskol wrote:DBUG, I am afraid but... you are the best !!!!
It is really impressive.

This demo shows that it is possible to get anything out of the oric...
really impressive... (my jaw is still on the floor...)
Well, I only adapted what we did on the Atari ST (same sound chip).

And both Fabrice and Twilighte made sample sound, and there is this Rambo demo of the Tivoli Pirat as well, so please give the credits to other people :)
Well, a last technical question about this wonderfull "welcome".

what is the sample rate of this ?

For example, imagine that I want to digitalize a sound effect and play it back :
- First I convert my little wav file to an unsigned 8 bits (but at which sample rate ?)
- then I extract the raw data (it is just a question of removing the wav header, and convert the binaries to a text file)
- finally I compile with OSDK

thank you
User avatar
Dbug
Site Admin
Posts: 4437
Joined: Fri Jan 06, 2006 10:00 pm
Location: Oslo, Norway
Contact:

Post by Dbug »

Good question.
I think it's 8khz, but I'm not sure.

Thing is, this routine does not use any timer, it is just disabling the interruptions and try to send stuff to the soundchip as fast as possible.

You probably noticed the 7 "nop" instructions, it's to slow down the replay.

The faster the loop, the higher the frequency :)

If you use a sample at a different (lower) frequency, you can just change the number of nop, or use instructions that take more time, this way you can play longer samples.

Also you can probably optimise the code quite a lot :)

If you use one channel instead of 3, the sound quality is a lot worse, but then you can use 4 bit samples, meaning that you store twice as many sample data in the same number of bytes, and you speedup the code by a HUGE factor (not x3, a lot more) because you can remove almost all the VIA register switching. Just need to select the volume register and write values in here as fast as you can :) - the methid we used to replay the 20th century fox and Digital DTS jingles in the other demos -
User avatar
Twilighte
Game master
Posts: 819
Joined: Sat Jan 07, 2006 12:07 am
Location: Luton, UK
Contact:

Post by Twilighte »

I wonder (Not tried it) what the effect on the sample would be if played alongside another channel setup with a high volume but not connected to tone generators?

I know (thru soundtracker) that when you play a sample in two channels it will sound more wholesome and louder.
Post Reply