PDA

View Full Version : AY-3-8910 sound chip



pullmoll
05-15-2010, 03:12 PM
I thought I had read somewhere that one of the forum members was going to try to create an object that emulates this chip? I can't find that post (or did I dream it)...
Anyway, I have been trying to convert attached C source into PASM, but I'm yet unsure if it will be feasible to emulate the AY this way. The attached code generates chunks of audio data and needs a streaming device (cog) to output the data at a constant (sample) rate. This would mean 2 cogs, one to generate the data and one to actually play it. I would rather have one cog doing all the work, if that is possible. I think it depends on how fast the 3 sound channels and the noise can be calculated in PASM. If the calculation is faster than the sample rate, the samples could be output immediately after calculation and the sample rate could be locked by using a waitcnt.
Perhaps those who know a bit more than I do about sound on the Propeller can elaborate on this issue?

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Pullmoll's Propeller Projects (http://pmbits.ath.cx/prop/)

Leon
05-15-2010, 06:55 PM
I interfaced one of those to my TRS-80 many years ago. Some of the arcade games at the time used them, IIRC.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Leon Heller
Amateur radio callsign: G1HSM

Dr_Acula
05-15-2010, 08:48 PM
It will be quite a job to replicate the code in pasm, but it would be a very worthy goal. I'm more familiar with the SN76489 but I think they were very similar chips. 3 tones and a noise generator. One cog would definitely be the goal, and it probably would spend a lot of time in wait states. Calculate everything, OR the signals, output the pin status, wait, repeat.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.smarthome.viviti.com/propeller (http://www.smarthome.viviti.com/propeller)

JonnyMac
05-15-2010, 10:09 PM
There is a SIDcog object that may be helpful. If memory serves me (haven't played with it in a while) it uses just one cog and handles ADSR for three oscillators.

http://forums.parallax.com/showthread.php?p=863861

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon McPhalen
Hollywood, CA

Ahle2
05-15-2010, 11:14 PM
Indeed doing it in one cog would be quite easy.
The SID chip is many times more complex compared to the ay8910, and still it was possible to do a quite good emulation of it in just one cog.
I even managed to fit the "analog" multimode resonance filter running in just one cog at a sample rate of near CD quality.

The AY8910 lacks almost everything that made the SID chip so complex for it's time.
If we take out Multimode filtering, Oscillator synchronization, Ring modulation, Variable pulse width, Saw waves, Triangle waves and combined waveforms from SIDcog we pretty much end up with an ay8910.
Then of course we have to alter the registers and severely cripple the envelope part. http://forums.parallax.com/images/smilies/smilewinkgrin.gif

We would probable end up with an emulation with a sample rate of almost twice that of a CD thanks to the simplicity of the chip.

Ahle2
05-15-2010, 11:31 PM
Btw, here is a SIDcog medley of 12 different C64 tunes.
gadgetgangster.com/scripts/displayasset.php?id=344 (http://gadgetgangster.com/scripts/displayasset.php?id=344)
Everything you hear is generated by one cog at 31Khz and output with PWM trough a RC filter.

pullmoll
05-15-2010, 11:43 PM
Ahle2 said...
We would probable end up with an emulation with a sample rate of almost twice that of a CD thanks to the simplicity of the chip.


Ok, then I may try to continue with what I began. The AY is really simple, that's true. And still it was widely used on computers and in arcade games, up to 5 chips per game it seems. The comments in the C source pretty much describe every important aspect of the chip and I think I can finish it. I just have to rethink the core update function to do everything for one sample only.

Thanks,
Juergen

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Pullmoll's Propeller Projects (http://pmbits.ath.cx/prop/)

Post Edited (pullmoll) : 5/15/2010 4:51:18 PM GMT

Ahle2
05-19-2010, 03:29 AM
Here is a complete emulation of the AY-3-891X (YM2149)

AYcog features:
- 60 kHz sample rate
- YM2149 or AY-3-8910 register structure
- Supports all waveforms ( Noise wave and 50:50 square wave )
- Can use advanced envelope tricks to produce other waveforms than square or noice (like the real thing)

Usage:

- Start AYcog with the public function "start(right,left)"
This function starts AYcog with audio out on the pins specified and returns a pointer to the first register of the the AY-3-891X.

- Put values in the 16 AY-3-891X registers and it should start making sound.

- One small difference from the real deal.
It's important that you set the 4th bit of the envelope shape register high everytime you change the register.
This is because there is no other way for the emulation to know if you have retriggered the register.
As soon as the emulator has read this bit it automatically sets it low again and it is ready for a new retrigger.
Example. If you want to put the value 9 (Decay) in the envelope shape register, you should set bit 4 high as well, resulting in value 9 + 16 = 25.
If you don't set this bit the envelope will not work.

/Ahle2

Baggers
05-19-2010, 04:01 AM
Nice one Ahle2 :) looks like you're keeping me busy with furthering the spectrum emulator, once it's running ;)

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
http://www.propgfx.co.uk/forum/·home of the PropGFX Lite

·

Ahle2
05-19-2010, 04:39 AM
Thanks Baggers ;)

Try this code for a complete runthrough of all possible AY sounds.



PUB Main | AYregisters, i, j, value, playRate

AYregisters := AY.start( audioR, audioL )

playRate := 5
repeat
waitcnt(cnt + 80_000_000/playrate)
repeat i from 0 to 15
value := (?j)&255
if i>9 and i<13
value &= 31
byte[AYregisters + i] := value



LOL

AntoineDoinel
05-19-2010, 04:54 AM
Ahle2 said...
- One small difference from the real deal.
It's important that you set the 4th bit of the envelope shape register high everytime you change the register.
This is because there is no other way for the emulation to know if you have retriggered the register.
As soon as the emulator has read this bit it automatically sets it low again and it is ready for a new retrigger.
Example. If you want to put the value 9 (Decay) in the envelope shape register, you should set bit 4 high as well, resulting in value 9 + 16 = 25.
If you don't set this bit the envelope will not work.
Ahle2, maybe·I'm missing something... but what if you reverse the polarity of that bit? (i.e. the app write normal values, the emu set it to 1 to detect next trigger) wouldn't that work?
·

Ahle2
05-19-2010, 04:59 AM
Of course it would..... Why didn't I think of that? Now I feel stupid :(
I will correct that.

AntoineDoinel
05-19-2010, 05:14 AM
btw, great job (again)!

next the hammond C3? http://forums.parallax.com/images/smilies/lol.gif
·

Ahle2
05-19-2010, 05:42 AM
Hammond C3, I don't think soo... ;)
Every PSG emulator I do tend to be simpler than the one before.
The only PSG I can think of that is more simple than the AY-3-891X is the two channel TIA chip used in Atari 2600.
The SID chip is A LOT more advanced compared to the AY-3-891X.

I think 31kHz samplerate for SIDcog and 60kHz samplerate for AYcog speaks for itself.

Post Edited (Ahle2) : 5/18/2010 10:48:54 PM GMT

pullmoll
05-19-2010, 06:24 PM
Ahle2 said...
Here is a complete emulation of the AY-3-891X (YM2149)


Thank you much! That was really quick!


Ahle2 said...
- Start AYcog with the public function "start(right,left)"


Is there probably a way to have it output on a single pin? I tried to detect if left == right and set a flag in that case, so that ctrb and frqb wouldn't be used. Unfortunately I don't hear anything at all yet. I have to fix my sound circuitry first (I use 1 pin #24 on the DracBlade). Edit: That output is still working with TRS80 and the single duty mode, so it has to be my modification that's wrong... I just hear a click when the cog is started and that's it.


Ahle2 said...
If you don't set this bit the envelope will not work.


Later you said you're going to fix this, so I should probably just map the first 8 registers 1:1 from the cgenie io.spin?
Edit: I think this is easy to fix. Just test EnvelopeShape, #16 and do the following things if_z only. Then or EnvelopeShape, #16 and write it back to hub RAM!?

Right now, after adding the AYcog to the list of objects, some games don't want to run anymore. This has to be a bug to do with memory somewhere, because also BASIC is behaving strange and giving me ?OM errors (out of memory). Anyway, that's my problem.


Thanks again,
Juergen

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Pullmoll's Propeller Projects (http://pmbits.ath.cx/prop/)

Post Edited (pullmoll) : 5/19/2010 2:06:09 PM GMT

Dr_Acula
05-19-2010, 08:38 PM
Hi pullmoll,

When you get your circuit right, please let me know what it is (even if it is just a resistor and capacitor) and I'll add that to the next board.

Sound is going to be a fantastic addition. Hmm - is there a cog free on the MP/M emulation?

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.smarthome.viviti.com/propeller (http://www.smarthome.viviti.com/propeller)

pullmoll
05-19-2010, 08:54 PM
Dr_Acula said...
When you get your circuit right, please let me know what it is (even if it is just a resistor and capacitor) and I'll add that to the next board.

There is no circuit, but just a 3,5mm jack for the audio out. I used a stereo jack, because I had no mono type available, and just connected port #24 to the output.
Assuming a 500Ohm aux input on the amplifier and max. wanted 1Vss level, you should probably go with a 1k1 resistor and perhaps a 1µF electrolytic capacitor in series with the output!? Perhaps like this:
http://forums.parallax.com/attachment.php?attachmentid=70474


Dr_Acula said...
Sound is going to be a fantastic addition. Hmm - is there a cog free on the MP/M emulation?

VT100 initialized, 0 cogs free.

Nope. We're out of cogs.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Pullmoll's Propeller Projects (http://pmbits.ath.cx/prop/)

Post Edited (pullmoll) : 5/19/2010 2:04:07 PM GMT

Ale
05-19-2010, 10:08 PM
Ahle2: Reversing the polarity always does the trick http://forums.parallax.com/images/smilies/wink.gif

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Visit some of my articles at Propeller Wiki:
MATH on the propeller propeller.wikispaces.com/MATH (http://propeller.wikispaces.com/MATH)
pPropQL: propeller.wikispaces.com/pPropQL (http://propeller.wikispaces.com/pPropQL)
pPropQL020: propeller.wikispaces.com/pPropQL020 (http://propeller.wikispaces.com/pPropQL020)
OMU for the pPropQL/020 propeller.wikispaces.com/OMU (http://propeller.wikispaces.com/OMU)
pPropellerSim - A propeller simulator for ASM development sourceforge.net/projects/ppropellersim (http://sourceforge.net/projects/ppropellersim)

pullmoll
05-19-2010, 10:18 PM
I got in working in cgenie now, but the sound isn't right. It looks as if it plays no envelope when it should and vice versa.
I do an or with #16 for writes to register #13.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Pullmoll's Propeller Projects (http://pmbits.ath.cx/prop/)

Ahle2
05-20-2010, 12:20 AM
Thank you much! That was really quick!


It was on my ToDo list anyway. You just gave me a reason to do it before year 2020. ;)



Is there probably a way to have it output on a single pin? I tried to detect if left == right and set a flag in that case, so that ctrb and frqb wouldn't be used. Unfortunately I don't hear anything at all yet. I have to fix my sound circuitry first (I use 1 pin #24 on the DracBlade). Edit: That output is still working with TRS80 and the single duty mode, so it has to be my modification that's wrong... I just hear a click when the cog is started and that's it.


start(0,24) will do the trick.
The start function takes care of everything including disablling of ctrb or ctra if either left or right is set to 0.



Later you said you're going to fix this, so I should probably just map the first 8 registers 1:1 from the cgenie io.spin?
Edit: I think this is easy to fix. Just test EnvelopeShape, #16 and do the following things if_z only. Then or EnvelopeShape, #16 and write it back to hub RAM!?


I know, I was just stupid for not doing exactly that from the beginning... (dooh)


Right now, after adding the AYcog to the list of objects, some games don't want to run anymore. This has to be a bug to do with memory somewhere, because also BASIC is behaving strange and giving me ?OM errors (out of memory). Anyway, that's my problem.


Okey, keep on debugging. :)

BTW, I will upload a new version with some changes shorthly.

JonnyMac
05-20-2010, 12:45 AM
You might want to use -1 as the "don't use" pin designation; this would allow output on P0.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon McPhalen
Hollywood, CA

Ahle2
05-20-2010, 02:43 AM
Okey, here is a new version with inverted reset bit functionality.

pullmoll said...
I got in working in cgenie now, but the sound isn't right. It looks as if it plays no envelope when it should and vice versa.
I do an or with #16 for writes to register #13.

That's very strange... according to the AY-3-891X documentation it should enable envelope when bit 4 of register 10, 11, 12 is set high.
Otherwise you might want to test to change


Env1 test amplitude1, val14bit wz
if_nz mov amplitude1, envelopeAmplitude


to


Env1 test amplitude1, val14bit wz
if_z mov amplitude1, envelopeAmplitude


(Remember, that's 3 changes, one for every channel)

WARNING
One thing to remember for emulator coders.
When writing to register 15 you have to "and" the byte with 15 / $F to not alter the "reset envelope flag".
Else the sound may be wrong if the emulated piece of code tries to (incorrectly) set bits 4-7 of the register.


Edit....
pullmoll,
I just saw that you ACTUALLY was talking about register 13. That's the low byte of the 16bit envelope period register.
What are you talking about?

Post Edited (Ahle2) : 5/19/2010 7:53:59 PM GMT

pullmoll
05-20-2010, 06:07 AM
Ahle2 said...
Okey, here is a new version with inverted reset bit functionality.
That's very strange... according to the AY-3-891X documentation it should enable envelope when bit 4 of register 10, 11, 12 is set high.
Otherwise you might want to test to change <snip>


That gives a slightly better set of sound effects, but there is still something seriously wrong.
Unfortunately I have not yet found the bug that causes PAINT.CMD to not work anymore. I guess you could judge by common sense that an accord of 3 tones, right after the startup of a game, that stays until something happens can't be quite right. I can describe the simple game FUSS.CMD sounds. When you move normally, it plays a little tune of 3 or 4 notes. When a rotating cross appears, there is a sweep from low to high frequencies which dies after abt. a second. Finally, when you eat one of the crosses that makes you immune to the poisoned red dots, there is the sound that you now hear right from the start.

All in all it looks like some or even most effects are done, but at the wrong times. It's hard to describe that. I could try to get my C version Colour Genie emulator up and running, because it has perfect sound.


Ahle2 said...

WARNING
One thing to remember for emulator coders.
When writing to register 15 you have to "and" the byte with 15 / $F to not alter the "reset envelope flag".
Else the sound may be wrong if the emulated piece of code tries to (incorrectly) set bits 4-7 of the register.


I did that and it makes no change.



Ahle2 said...
I just saw that you ACTUALLY was talking about register 13. That's the low byte of the 16bit envelope period register.
What are you talking about?


According to my specs, register #13 (zero based) is the envelope shape register. The enumeration is in the text file I attached to the first post, the C source of the AY-3-8910 emulation. REG_EFINE (the low byte of the envelope period) is register #11.


For the records, here's the enum:


REG_AFINE,
REG_ACOARSE,
REG_BFINE,
REG_BCOARSE,
REG_CFINE,
REG_CCOARSE,
REG_NOISEPER,
REG_ENABLE,
REG_AVOL,
REG_BVOL,
REG_CVOL,
REG_EFINE,
REG_ECOARSE,
REG_ESHAPE,
REG_PORTA,
REG_PORTB,




I posted an updated version cgenie-0.1.5 in this thread (http://forums.parallax.com/showthread.php?p=905672).

Edit: Updated again, because I found the reason for the strange sounds: the value REGISTER_OFFSET has to be 1, just like for the YM chip. Where did you get your port numbers from? They're wrong for the amplitudes and everything else following.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Pullmoll's Propeller Projects (http://pmbits.ath.cx/prop/)

Post Edited (pullmoll) : 5/20/2010 6:11:59 AM GMT

Ahle2
05-20-2010, 02:26 PM
According to my specs, register #13 (zero based) is the envelope shape register. The enumeration is in the text file I attached to the first post, the C source of the AY-3-8910 emulation. REG_EFINE (the low byte of the envelope period) is register #11.

According to the official specs the AY has a 2 byte gap between the "enable register" and "channel A amplitude register".
http://map.grauw.nl/resources/sound/generalinstrument_ay-3-8910.pdf
The YM-2149F on the other hand has the specs you are talking about.
http://www.ym2149.com/ym2149.pdf
Take an unaltered version of AYcog_V0-16.spin (http://forums.parallax.com/attachment.php?attachmentid=70481)·and just enable the YM instead and see if that's works.
If so, it seems like the Color Genie actually has an YM chip and not an AY.

/Ahle2

AntoineDoinel
05-20-2010, 04:54 PM
Gents,

by looking at the AY-3-8910 datasheet I got the feeling that R0..R7 and R10..R17 in register name notation is OCTAL and not decimal.
So registers are really still R0..R15. The width of register select pins (page 5-19) is 4 bits, so it make sense.
In the end the register map should be identical for both chips.

I also tried to match this hypotesis with some other source (http://www.atarimagazines.com/v4n7/stsound.html), and that seems to confirm it.
But consider I never programmed such a chip so I could be wrong.

Regards
Alessandro

pullmoll
05-21-2010, 12:05 AM
I haven't looked into the official data sheet, but Alessandro is certainly right. There is no such thing as a gap in register numbers on the AY, that's for sure.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Pullmoll's Propeller Projects (http://pmbits.ath.cx/prop/)

Ahle2
05-21-2010, 12:29 AM
pullmoll said...
I haven't looked into the official data sheet, but Alessandro is certainly right. There is no such thing as a gap in register numbers on the AY, that's for sure.

After doing some research it seems like you are right.
I did all of my coding based on the official AY-3-8910 documentation and I didn't realize they used octal numbers for registers in the AY-3-8910 doc but decimal numbers in the YM-2149F doc.

pullmoll, it's STILL important that you set all constants to the YM setup and not just "REGISTER_OFFSET=1" like you did
It should look like


REGISTER_OFFSET = 1
LONG_CORRECTION = 2
DUMMY_VARIABLE = 0


Otherwise envelopePeriod register will be faulty.

pullmoll
05-21-2010, 01:26 AM
Ahle2 said...
pullmoll, it's STILL important that you set all constants to the YM setup and not just "REGISTER_OFFSET=1" like you did


What about attached version 0-17? I removed the constants altogether and made the AYregisters a parameter, so that the calling object defines the register set. That way it is easy for a caller to give useful names to the registers and/or to deal on its own with the digital port A and B.
Also note that an envelope period of 0 is actually half the length of a period of 1, i.e. it is not zero! This info is from the MAME project's AY/YM emulation.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Pullmoll's Propeller Projects (http://pmbits.ath.cx/prop/)

Post Edited (pullmoll) : 5/20/2010 6:51:40 PM GMT

Ahle2
05-21-2010, 04:56 AM
I will look at your suggestions tomorrow when I'm not tired.... "Coder needs sleep badly"

Here is an example of playback of AY register dumps from various AY tunes.
Unpack the ym files to a freshly formated SD card and run "AYDumpPlayExample.spin" and enjoy.

pullmoll
05-21-2010, 07:16 AM
Ahle2 said...
I will look at your suggestions tomorrow when I'm not tired.... "Coder needs sleep badly"

Here is an example of playback of AY register dumps from various AY tunes.
Unpack the ym files to a freshly formated SD card and run "AYDumpPlayExample.spin" and enjoy.


Cool! Not as nice as SID songs, of course, but still nice.

Here's a suggestion for an openNextFile that selects just *.ym files - the others sound a bit strange http://forums.parallax.com/images/smilies/smile.gif


PUB openNextFile | i, j, t
sd.opendir
repeat i from 0 to fileNumber
sd.nextfile( @filename )
repeat j from 0 to strsize(filename)
if filename[j] == "."
quit
j++
if filename[j] <> "Y" or filename[j+1] <> "M"
i--
if sd.popen( @filename, "r" ) == -1
sd.pread(@buffer, 14)
repeat i from 1 to 3
sd.pread(@buffer, 16)




The player works with my modified -0-17 as well. It seems the Microtan could have an add-on with 2 AYs, so I'm going to add your code there too. With the caller defining the AYregisters that's no problem.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Pullmoll's Propeller Projects (http://pmbits.ath.cx/prop/)

Post Edited (pullmoll) : 5/21/2010 12:25:19 AM GMT

Ahle2
05-22-2010, 10:52 PM
Here is a new version of AYcog.

AYcog v0.20 improvements:
- 13% smaller
- 2.08 times higher sample rate. (125kHz)
- Fixed some small timing errors
- Logarithmic volume for "fixed" amplitude values as well.
(v0.16 had logarithmic volume when using envelopes only)

FAQ
Q. Why would it matter to have a better sample rate than twice (according to nyquists theorem) the human range when people can't hear those high frequencies anyway ?
A. To minimize audiable aliasing distortion when playing high notes.

Q. How come AYcog has a sample rate 4 times that of SIDcog when both PSGs has got 3 audio channels ?
A. The SID chip is many times more advanced compared to the AY-3-8910, plus it has got a multimode analog filter.

@pullmoll
It's very important that the AY registers are aligned to long address plus a two byte offset otherwise the getRegister subroutine will fail to get the correct values.

Valid addresses are:
0 + 2 = 2
4 + 2 = 6
8 + 2 = 10
12 + 2 = 14
16 + 2 = 18
etc
etc
That's the reason why I don't think it's a good idea to to let the user choose the address.

Btw, I've added your modified version of openNextFile to the new dump player example.

I will look at the division by zero problem you were talking about when I find the time.

/Ahle2

pullmoll
05-22-2010, 11:05 PM
Ahle2 said...

It's very important that the AY registers are aligned to long address plus a two byte offset otherwise the getRegister subroutine will fail to get the correct values.


I am aware of the rdword and rdlong requirements. I had changed the reading of the envelope period to two rdbytes and also read the envelope shape as a byte.
I always align structures to a long boundary when they are also passed to some other function.


Ahle2 said...

That's the reason why I don't think it's a good idea to to let the user choose the address.


Well, there are quite a few objects that allow passing a pointer to a structure from the calling function. You could even abort out if an alignment test fails.



Ahle2 said...

I will look at the division by zero problem you were talking about when I find the time.


It's not a division by zero issue, but a counter value = 0 issue. It's simple to fix, too. I just tested the envelope period == 0 and in that case loaded it with 128 instead of shifting it 8 times to left. That way the period equals half that of the counter value 1.

Edit: In the player you have a bytemove(AYregisters, @buffer, 12) which moves bytes 0 to 11, but not byte #12, so the high byte of envelope period stays at 0.
Edit2: Here's my modification allowing external regs, including alignment check and handling of envelopePeriod==0.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Pullmoll's Propeller Projects (http://pmbits.ath.cx/prop/)

Post Edited (pullmoll) : 5/22/2010 5:08:16 PM GMT

Baggers
05-23-2010, 03:49 AM
Sounds great Ahle2 :) brings back memories ;)

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
http://www.propgfx.co.uk/forum/·home of the PropGFX Lite

·

Ahle2
05-23-2010, 05:38 AM
pullmoll said...
Edit: In the player you have a bytemove(AYregisters, @buffer, 12) which moves bytes 0 to 11, but not byte #12, so the high byte of envelope period stays at 0.

Ooops, I didn't see that one.

The YM format handles the "don't write to register 13" like this:
- If register 13 is equal to 255 it's not supposed to be written to the memory in that frame.
- If it contains anything else it's supposed to be written to the memory in that frame.

This is because otherwise it would be impossible to playback tunes that used the envelope.
Everytime you write something to register 13 it resets the envelope, and of course that's not to supposed to happen every vbl.



pullmoll said...
Edit2: Here's my modification allowing external regs, including alignment check and handling of envelopePeriod==0.

I will have a look at it tomorrow.

Cheers.

Ahle2
05-23-2010, 06:01 AM
Pullmull, after looking at your modifications I agree.... that's a keeper.
Thanks.

pullmoll
05-23-2010, 11:53 PM
Ahle2 said...
Pullmull, after looking at your modifications I agree.... that's a keeper.
Thanks.


I have to thank you for your efforts! If I will some day track down the last bugs in qZ80, and find a way to handle the CRTC writes more appropriately, I have an almost complete Colour Genie in one chip.. err, two with the RAM.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Pullmoll's Propeller Projects (http://pmbits.ath.cx/prop/)

Ahle2
05-24-2010, 04:42 PM
·Baggers said...
Sounds great Ahle2 :) brings back memories ;)
So when are we going to see your Spectrum 128 emulator with full sound support and everything? http://forums.parallax.com/images/smilies/turn.gif

Ahle2
05-24-2010, 05:56 PM
I've found a list of systems using the AY-3-891X (or compatible) sound IC.

Homecomputers
•Amstrad CPC (AY-3-8912)
•Atari Falcon 030 (YM3439)
•Atari ST (YM2149)
•EACA Colour Genie (AY-3-8910)
•Fujitsu Micro 7 (FM-7) (AY-3-8910)
•Mitsubishi Multi 8
•MSX (AY-3-8910)
•NEC PC-6001 / MK2 / MK2 SR / 6601 (AY-3-8910)
•Oric 1 (AY-3-8912)
•Oric Atmos (AY-3-8912)
•Oric Telestrat (AY-3-8912)
•Samsung SPC-1000 (AY-3-8910)
•Sharp MZ5500 (AY-3-8912)
•Sharp X1 (AY-3-891x)
•Sinclair ZX Spectrum 128/+2/+3 (AY-3-8912)
•Timex Sinclair 2068 / 2048 (AY-3-8912)

Sound Cards
•Applied Engineering Phasor (for Apple II) (AY-3-8913)
•AY-Magic (for ZX-Spectrum) (AY-3-8910 or YM2149F)
•Didaktik Melodik (for ZX-Spectrum) (AY-3-891x)
•EME Sound Box (for Jupiter Ace) (AY-3-8910)
•HAL GSX-8800 (for PC-8001 and PC-8801) (AY-3-8910)
•Sweet Microsystems Mockingboard (for Apple II) (AY-3-8913)
•Sweet Microsystems Sound I (for Apple II) (AY-3-8910)
•Sweet Microsystems Sound II (for Apple II) (AY-3-8910)

Video Game Consoles
•Amstrad GX 4000 (AY-3-8912)
•Bandai Supervision 8000 (AY-3-8910)
•Elektor TV Games Computer (AY-3-8910)
•Mattel Intellivision (AY-3-8914)
•Vectrex (AY-3-8912)

Arcade Systems
•Irem M-27 (AY-3-891x)
•Irem M-52 (AY-3-891x): 10 Yard Fight..
•Irem M-62 (YM-2149): Lode Runner, Spelunker
•Irem M-63 (AY-3-891x): Atomic Boy, Fighting Basketball..
•Scramble Hardware (AY-3-8910 x2): Scramble, Amidar..
•Taito System SJ (AY-3-891x): Elevator Action, Jungle Hunt…
•many other Arcade PCBs..

Baggers
05-24-2010, 07:46 PM
Ahle2, I'm having some troubles getting the spectrum working at the moment, well it works as a spectrum, it boots to the logo, and you can type in your programs etc.
but if I load a file and try to run it, it doesn't want to play.
I'm busy sorting legal stuff with work at the mo, so don't have much time, yet again, but will get back to it VERY soon :) and figure out why it's not loading and running an app.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
http://www.propgfx.co.uk/forum/·home of the PropGFX Lite

·

Dr_Acula
05-25-2010, 08:23 AM
I'm thinking about a small audio amplifier on the dracblade. See attached. The chip is 55c from Futurlec, and yes, it is not the best audio amp but on the other hand, we are talking square wave retro sound here. I've used P28 which is the eeprom clock line, but I'd appreciate some feedback about whether to use other pins. Or maybe a couple of jumpers so you can select which pin.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.smarthome.viviti.com/propeller (http://www.smarthome.viviti.com/propeller)

lynchaj
05-25-2010, 06:40 PM
Ahle2 said...
I've found a list of systems using the AY-3-891X (or compatible) sound IC.

Homecomputers
[snip]
Hi!· Just recently we released an SCG board for the N8VEM system.· It includes a TMS9918 for Sprites and Color Graphics and also a AY-3-8910 for Sound and joystick/paddles.

Really it should called SCGS but the name SCG kind of stuck.· The PCBs are out with the builders and I am hoping to see the first results of the initial build and test here shortly.

This is just FYI in case anyone is interested in a recent system with a real AY-3-8910 chip.

Thanks and have a nice day!

Andrew Lynch

JonnyMac
05-26-2010, 12:03 AM
Dr_Acula said...
I'm thinking about a small audio amplifier on the dracblade. See attached. The chip is 55c from Futurlec, and yes, it is not the best audio amp but on the other hand, we are talking square wave retro sound here. I've used P28 which is the eeprom clock line, but I'd appreciate some feedback about whether to use other pins. Or maybe a couple of jumpers so you can select which pin.


You may want to use a capacitor to couple the pin to the amp so that a 0 setting on the pot doesn't "kill" the SCL line when the Propeller is booting. The TDA7052 is another small amplifier that's easy to use, and seems to be less issue prone.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon McPhalen
Hollywood, CA

pullmoll
05-26-2010, 09:16 PM
I think there's a bug in the emulation. Listen to the attached YM file to hear what I mean. There's a very low frequency static in the background all the time. I think this could happen when the frequency of a channel is set to 0? In that case the channel should be silent AFAICS, as 0 for the frequency really means: no counting!?

The same low frequency hum is in the background of Crazy Paint's tune, too. I think I played silence as freq=0 there as well.

Edit: Also attached - a lot more YM6 files and a YM6 player. It scans the header fields and prints some song info to the serial port. You can skip a song by pressing any key. The songs can (should) be in a subdirectory "YM" on the SD card. The included ym5to6.c source allows conversion of the (much more frequent) YM5 file format to YM6. You may have to LZH decompress the YM5 file first.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Pullmoll's Propeller Projects (http://pmbits.ath.cx/prop/)

Post Edited (pullmoll) : 5/26/2010 4:50:52 PM GMT

Ahle2
05-27-2010, 01:41 AM
My initial YM dump player was just a QUICK hack to get something playing and I didn't handle the header at all.
Soon I will release my chip-tune player with fullscreen oscilloscope and on-screen information. :)

It will feature:
- SID playback of *.dmp files (created with my "SID-dumper" tool from SIDs)
- AY/YM playback of *.YM files (created with Leonards AY/YM tools)
- 60Hz fullscreen oscilloscope
- Song information
- Nice looking demo-like UI
- Everything running on the propeller of course

I'm thinking about adding support for POKEY and NES tunes as well. :)

@pullmoll
I will look at the bug as soon as I get a change.

Ahle2
05-27-2010, 01:52 AM
BTW, here are some more nice YM tunes. :)

Ahle2
05-27-2010, 03:02 AM
After altering


'───────────────────────────────────────────────── ──────────
Square1 sub phaseAccumulator1, oscSubValue wc ' Square wave generator
if_c add phaseAccumulator1, frequency1 ' channel 1
if_c xor oscValues, #1
'───────────────────────────────────────────────── ──────────


To


'───────────────────────────────────────────────── ──────────
Square1 cmp frequency1, freqRef wc
if_nc sub phaseAccumulator1, oscSubValue wc ' Square wave generator
if_c add phaseAccumulator1, frequency1 ' channel 1
if_c xor oscValues, #1
'───────────────────────────────────────────────── ──────────


for every channel.
Both alliasing distortion when outputing higher than human frequencies, as well as freq = 0 are handled.

potatohead
05-27-2010, 04:41 AM
Can I put in a vote for TIA??

At some point, I need to go back and finish the FREEWAY game. There is plenty of RAM for sounds...

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Propeller Wiki: Share the coolness! (http://propeller.wikispaces.com/)
8x8 color 80 Column NTSC Text Object (http://obex.parallax.com/objects/550/)
Safety Tip: Life is as good as YOU think it is!

Chris Savage
05-27-2010, 06:54 AM
Hey everyone, I haven't been following this thread all the way through, however when I saw the title it took me back to the late 80s where many Arcade machines used to use this IC as well. I also saw recently that B.G. Micro has 24 left at $3.95 each (http://www.bgmicro.com/icsay38910.aspx).

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage

Parallax Engineering
·

pullmoll
05-28-2010, 01:31 AM
Ahle2 said...
Both alliasing distortion when outputing higher than human frequencies, as well as freq = 0 are handled.


Sounds quite right now. Thanks!

BTW I found an old piece of source code of mine: a MOD player written in C. I think it should be possible to load samples from XMM, if the hub RAM isn't sufficient to hold all samples of a MOD file. That would be a nice addition to your sound player!?

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Pullmoll's Propeller Projects (http://pmbits.ath.cx/prop/)

Post Edited (pullmoll) : 5/27/2010 6:38:35 PM GMT

Ahle2
05-28-2010, 03:08 AM
potatohead said...
Can I put in a vote for TIA??

Of course you can. http://forums.parallax.com/images/smilies/wink.gif

pullmoll said...
Sounds quite right now. Thanks!

Great to hear.
Now I want to see a YouTube clip of Crasy Paint with sound and everything. http://forums.parallax.com/images/smilies/smilewinkgrin.gif

Chris Savage said...
when I saw the title it took me back to the late 80s where many Arcade machines used to use this IC as well

I'm guessing that over half of the arcade machines in the early to mid 80s had at least one AY-3-891X on board.

hover1
05-28-2010, 03:16 AM
Chris,

Thanks for the heads up. I haven't been to that sight in a while and found some other stuff I was looking for!

Jim


Chris Savage (Parallax) said...
Hey everyone, I haven't been following this thread all the way through, however when I saw the title it took me back to the late 80s where many Arcade machines used to use this IC as well. I also saw recently that B.G. Micro has 24 left at $3.95 each (http://www.bgmicro.com/icsay38910.aspx).

Oldbitcollector (Jeff)
05-28-2010, 09:07 AM
Had this happily playing in my office all afternoon. Great job Ahle and Pullmoll!

Where on earth did you come up with all the great .ym files? This stuff is so dated that even Google doesn't have a clue.

OBC

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Are you Propeller Powered?
Propeller Feature Projects: PropellerPowered.com (http://www.propellerpowered.com)
Visit the: PROPELLERPOWERED SIG forum (http://www.savagecircuits.com/forums/forumdisplay.php?29-Propeller-Powered) kindly hosted by Savage Circuits (http://www.savagecircuits.com).

pullmoll
05-29-2010, 06:37 PM
Ahle2 said...
Now I want to see a YouTube clip of Crasy Paint with sound and everything. http://forums.parallax.com/images/smilies/smilewinkgrin.gif


There you go: http://www.youtube.com/watch?v=n-qgkdjqTMc
Sorry for the missing right edge of the screen. Space is too tight on my desktop http://forums.parallax.com/images/smilies/wink.gif The sound quality is also low, because my camera is recording at 11025Hz. Uploaded the file as is and the sound is okay now.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Pullmoll's Propeller Projects (http://pmbits.ath.cx/prop/)

Post Edited (pullmoll) : 5/29/2010 12:58:39 PM GMT

Ahle2
05-29-2010, 07:14 PM
The sound works for me!

Baggers
05-29-2010, 07:20 PM
where's the posted vid?

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
http://www.propgfx.co.uk/forum/·home of the PropGFX Lite

·

Ahle2
05-29-2010, 07:23 PM
http://www.youtube.com/watch?v=hZ4WwghJido
He deleted the link because he thought the sound was broken.

pullmoll
05-29-2010, 08:21 PM
Ahle2 said...
http://www.youtube.com/watch?v=hZ4WwghJido
He deleted the link because he thought the sound was broken.


It was offset by several seconds. This must have happened in the conversion I tried. Now I'm uploading another clip... 8:01 and 417MBs *yawn*

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Pullmoll's Propeller Projects (http://pmbits.ath.cx/prop/)

Baggers
05-29-2010, 08:52 PM
Worked for me, offset or no offset, still has sound :)

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
http://www.propgfx.co.uk/forum/·home of the PropGFX Lite

·

mpark
05-29-2010, 10:02 PM
Amazing work all around!

Oldbitcollector (Jeff)
05-29-2010, 10:28 PM
@Ahle2

Is is possible to use this object (AY-3-8910) in conjunction with another sound object? (say, Chip's speech object?)
It would be extremely handy for a couple projects I'm working on.

Thanks!
OBC

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Are you Propeller Powered?
Propeller Feature Projects: PropellerPowered.com (http://www.propellerpowered.com)
Visit the: PROPELLERPOWERED SIG forum (http://www.savagecircuits.com/forums/forumdisplay.php?29-Propeller-Powered) kindly hosted by Savage Circuits (http://www.savagecircuits.com).

Cluso99
06-03-2010, 01:59 PM
@Ahle2: Am I correct in presuimg you only require 1 prop pin and a cog for this?

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Links to other interesting threads:

· Home of the MultiBladeProps: TriBlade (http://forums.parallax.com/showthread.php?p=786418),·RamBlade (http://forums.parallax.com/showthread.php?p=849265),·SixBlade (http://forums.parallax.com/showthread.php?p=780033), website (http://bluemagic.biz/cluso.htm)
· Single Board Computer:·3 Propeller ICs·and a·TriBladeProp board (ZiCog Z80 Emulator) (http://forums.parallax.com/showthread.php?p=790917)
· Prop Tools under Development or Completed (Index) (http://forums.parallax.com/showthread.php?p=753439)
· Emulators: CPUs Z80 etc; Micros Altair etc;· Terminals·VT100 etc; (Index) (http://forums.parallax.com/showthread.php?p=778427) ZiCog (Z80) (http://forums.parallax.com/showthread.php?p=788511) , MoCog (6809) (http://forums.parallax.com/showthread.php?p=811043)·
· Prop OS: SphinxOS (http://forums.parallax.com/showthread.php?p=819353)·, PropDos (http://www.orrtech.us/propdos/) , PropCmd (http://obex.parallax.com/objects/440/)··· Search the Propeller forums (http://www.google.com/advanced_search?q=+site:forums.parallax.com&num=20&hl=en&lr=)·(uses advanced Google search)
My cruising website is: ·www.bluemagic.biz (http://www.bluemagic.biz)·· MultiBlade Props: www.cluso.bluemagic.biz (http://www.cluso.bluemagic.biz)

pullmoll
06-03-2010, 04:21 PM
Cluso99 said...
@Ahle2: Am I correct in presuimg you only require 1 prop pin and a cog for this?

Yes, 1 pins is sufficient. The communication is through 16 bytes of hub RAM reflecting the AY-3-891x registers.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Pullmoll's Propeller Projects (http://pmbits.ath.cx/prop/)

Cluso99
06-03-2010, 05:23 PM
Thanks pullmoll. I saw your interface is 1K1 series, 470R to ground, and 1uF series to output. I shall give that a try with some headphones and also my TV.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Links to other interesting threads:

· Home of the MultiBladeProps: TriBlade (http://forums.parallax.com/showthread.php?p=786418),·RamBlade (http://forums.parallax.com/showthread.php?p=849265),·SixBlade (http://forums.parallax.com/showthread.php?p=780033), website (http://bluemagic.biz/cluso.htm)
· Single Board Computer:·3 Propeller ICs·and a·TriBladeProp board (ZiCog Z80 Emulator) (http://forums.parallax.com/showthread.php?p=790917)
· Prop Tools under Development or Completed (Index) (http://forums.parallax.com/showthread.php?p=753439)
· Emulators: CPUs Z80 etc; Micros Altair etc;· Terminals·VT100 etc; (Index) (http://forums.parallax.com/showthread.php?p=778427) ZiCog (Z80) (http://forums.parallax.com/showthread.php?p=788511) , MoCog (6809) (http://forums.parallax.com/showthread.php?p=811043)·
· Prop OS: SphinxOS (http://forums.parallax.com/showthread.php?p=819353)·, PropDos (http://www.orrtech.us/propdos/) , PropCmd (http://obex.parallax.com/objects/440/)··· Search the Propeller forums (http://www.google.com/advanced_search?q=+site:forums.parallax.com&num=20&hl=en&lr=)·(uses advanced Google search)
My cruising website is: ·www.bluemagic.biz (http://www.bluemagic.biz)·· MultiBlade Props: www.cluso.bluemagic.biz (http://www.cluso.bluemagic.biz)

pullmoll
06-03-2010, 06:17 PM
Cluso99 said...
Thanks pullmoll. I saw your interface is 1K1 series, 470R to ground, and 1uF series to output. I shall give that a try with some headphones and also my TV.

That was just a wild guess to have ~ 1V output at 500Ohms, which is the standard AUX input parameters IIRC. It should work with headphones. The capacitor value is just a guess taken from some amplifier's input circuitry.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Pullmoll's Propeller Projects (http://pmbits.ath.cx/prop/)

Ahle2
06-03-2010, 11:18 PM
Oldbitcollector said...
@Ahle2

Is is possible to use this object (AY-3-8910) in conjunction with another sound object? (say, Chip's speech object?)
It would be extremely handy for a couple projects I'm working on.

Thanks!
OBC

Yes it would, but not on the same output.
AYcog/SIDcog to the left and the speech object to the right.

Oldbitcollector (Jeff)
06-04-2010, 12:23 AM
Got it! Thanks!

OBC

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Propeller Feature Projects: PropellerPowered.com (http://www.propellerpowered.com)
Visit the: PROPELLERPOWERED SIG forum (http://www.savagecircuits.com/forums/forumdisplay.php?29-Propeller-Powered) kindly hosted by Savage Circuits (http://www.savagecircuits.com).

fezmonkey
06-27-2010, 11:22 AM
I do not have an SD card but I really want to try this driver so I included a ym file in the build and modified the code to copy data from the included file instead of from the SD card. I am not able to make it work no matter what I do!!

Here is the code I modified

i:=14+16+16+16 '' the starting pointer
repeat until (i>4000)'this is just an estomate for now
waitcnt(cnt+playRate)
'if( sd.pread(@buffer, 16) ) => 0
bytemove( @buffer, @data+i, 16 )' instead of read from SD I read from file I added
i +=16'increment the pointer by 16
bytemove( @AYregs, @buffer, 13 )
ifnot buffer[13] == 255
byte[@AYregs + 13] := buffer[13]&15

.................
............
..............
DAT
data file "jess2.ym"



edit: haha!! I found the error. The code reads the first 14+16+16+16 bytes (the header) but the header is not necessary to be this size! I kinda kept messing with numbers until I had it to work.
Does anyone know where I can find the spec fro the ym files?

Whoever made this....very nice work

Post Edited (fezmonkey) : 6/27/2010 4:52:45 AM GMT

Ahle2
06-27-2010, 05:34 PM
fezmonkey said...
Whoever made this....very nice work

That would be me. Thanks!

I'm sorry about the header thing. http://forums.parallax.com/images/smilies/sad.gif
All my initial test dumps had the same header size and I was eager to get it to play as soon as possible.
I just took a short cut and kind of forgot about it.
pullmoll made a player that handles the header correctly, you can find it somewhere in this thread.

(BTW, I hope you use the latest version of AYcog since it is improved a lot)

/Ahle2

pullmoll
06-27-2010, 07:46 PM
fezmonkey said...

Does anyone know where I can find the spec fro the ym files?



I can't remember the website where I have this from, but here it is:

4 bytes "YM6!" - indication of a non-interleaved YM file (YM5! is interleaved by 16)
8 bytes "LeOnArD!"
4 bytes number of frames (long)
4 bytes attributes
2 bytes number of drum samples (usually 0)
4 bytes YM2149/AY-3-891x frequency in Hz (usually 1MHz or 2MHz)
2 bytes player frequency in Hz (usually 50)
4 bytes loop start (if non 0)
2 bytes extra bytes following
xxx bytes extra bytes
yyy bytes drum samples, if any; each sample entry consists of
--- 4 bytes length of sample
--- zzz bytes sample data
NUL terminated string song name
NUL terminated string author name
NUL terminated string comments / software
YM data follows


HTH
Juergen

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Pullmoll's Propeller Projects (http://pmbits.ath.cx/prop/)

Ding-Batty
06-27-2010, 08:21 PM
Google is your friend:

leonard.oxg.free.fr/ymformat.html (http://leonard.oxg.free.fr/ymformat.html)

fezmonkey
06-27-2010, 10:46 PM
>> (BTW, I hope you use the latest version of AYcog since it is improved a lot)

I am using version 22 as this is the latest I could find. Files are playing just fine.

Thanks to your driver and Andy's video driver, I have now somewhat complete system for the FEZ Gameo project.http://www.microframeworkprojects.com/index.php?title=FEZ_Gameo

I should be able to show some cool demo in couple days

Ahle2
06-28-2010, 02:49 AM
Looking forward to it.
I may be interested in one of those. :)

BTW, you may be interested in SIDcog as well. It's an emulation of the much more powerful SID chip in the C64.

Post Edited (Ahle2) : 6/27/2010 8:21:24 PM GMT

fezmonkey
06-28-2010, 06:49 AM
Here is a video of what we have so far. This is far from done but very good progress
http://www.youtube.com/watch?v=aDzzMENJf8g


Ahle2 said...
I may be interested in one of those. :)

I maybe able to get you one for free if you are willing to help out ;)


SIDcog, I looked it up on this forum but I do not understand anything about SID or audio so I am going to stick with the current driver for now. The important part is to make a complete project that is all open so the anyone (you) can take ti and make it better anyway they like.

Baggers
06-28-2010, 06:05 PM
fez, why would you say in your video that programming in spin is very hard and also for someone who knows c or c++ would find spin very very difficult?
I've been writing with C for years, and found my spin very easy to get to grips with.

It's comments like yours that keep other people away from the propeller :( please try and by more positive about spin in your videos ;) we need more people coming to the prop, so they too can find out what a great little chip it is, and easy to program, and very easy and very quick to prototype with. ( it even has a C compiler and PropBASIC ).

Sorry for my little rant, but the prop deserves good press, and to me, that video says, get a gameo, it's very difficult to program with, so you're going to frighten away anyone who would want to get a gameo.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
http://www.propgfx.co.uk/forum/·home of the PropGFX Lite

·

heater
06-28-2010, 06:42 PM
fezmonkey: I have to wonder about these statements from the video:

"Spin ...very very difficult", "Some what OK[for familiar users]", "Any programmer out there that knows C or C++ would find this very difficult to understand".

That is so far from the truth. Any programmer out there who has been working with anything since the dawn of structured programming from ALGOL through C to Z will pick get the idea of Spin in a one hour scan of the manual and be up to speed in no time. There are no new concepts in there.

OK PASM is harder but still about the easiest assembly language going.

Admittedly all that audio/video code maybe beyond what a lot of people are used to or want to get into. But that's in the nature of the task rather than the languages or IDE used to do it.

Lets look at this the other way round. In Spin/PASM on the Prop it is possible to do those audio/video things. In C++/C# on the Fez or other platform it is very HARD.

With that out of the way the whole Gameo idea is quite interesting. Moving all the high level "management" or game logic out of the Propeller which is memory constrained. I have often though a marriage of a Prop and an ARM on a single PCB would be great.

The FEZ Domino card has a very attractive price (60 Euros) so it fits the plan perfectly.

Can I program this setup from Linux?

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
For me, the past is not over yet.

fezmonkey
06-28-2010, 08:02 PM
I do embedded programming for living (over 15 years) and have always use C/C++. Moving to program FEZ Domino in C# was very easy for me. Now, programming in SPIN, not easy at all, at least for me. I am now on my forth week trying to learn spin and I still get stuck in many places where I get very frustrated.

I guess if you know SPIN only and wanted to program in C then you will have the same problem, C will be very difficult!

Either way, the propeller chip is amazing at generating signals (that is why it was chosen for the project) and SPIN is not bad but I wish it was closer to C so it is easier to learn.
Maybe by next video I will be less frustrated with spin (learned more) and have more positive attitude toward spin :)

Sorry guys if I upset anyone

About Linux, theoretically, this is a .NET interpreter so it can run any .NET assembly...coming from windows or Linux ....if ti was programmed in C# or VB....all should work. That is in theory. In reality, C# is fully supported and VB has been proven to run but no one had tried to make it work on linux.

heater
06-28-2010, 08:31 PM
Fezmonkey, you are right about that. The hardest thing is when you find yourself programming in C and Spin at the same time. Things are similar enough that you keep finding yourself using one syntax in the other. Which mostly just produces a compiler error but sometimes compiles fine and then does unexpected things. For example when you think you are commenting out a block of code with {} in C. Syntax highlighting normally alerts one to these things but sometimes they slip through.

It's better to have time in each language to get into the correct habits.

So is it possible to compile C# with Mono under Linux that would run on that board? What libs might it need? How would the executable get downloaded?

Any links to any clues about this?

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
For me, the past is not over yet.

Baggers
06-28-2010, 08:48 PM
exactly, there are differences between spin and C, the problem is you want to stick with something you know.
people should try the prop, and realise how easy it is, here's an example, your video to show people how to use the FEZ-Domino to flash a single LED
create a new project, add a few using lines, for the thread instructions, and for the pin defines, then you can write your code.

prop is just, open the proptool then type



pub main
dira[ 0 ]:=1
repeat
!outa[0]
repeat 5000




surely that's a lot more Freaking Easy than the FEZ-Domino is? :)

How long did it take for you to get use to classes etc in C? when they brought out C++? and again, when you moved to C# from C++?

And like heater said, would it be easy for you to write a TV display driver on the FEZ?

I know arm, inside out, been programming on it for 9 years (in both C and ASM), which is 3 times longer than I've had a prop for ( about 3 years ) and I know, that I would rather write a TV driver for the prop than do one on an arm chip.

sometimes to advance you need to step outside of your comfort zone and just jump into the water, either the deep end or the shallow end, but at least get your feet wet before totally dismissing it, or using words like "very very hard"

What about people who program other microcontrollers, pic, avr or sx chips, it's like you're telling them spin is very very hard, compared to C#, whereas I'd say it would be a lot easier to learn spin than it would to learn C# for someone who doesn't know C.

btw, you haven't upset me, I just think it a bit unfair you dissed the prop without even realising it, not to mention possibly frightened away potential prop newbies.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
http://www.propgfx.co.uk/forum/·home of the PropGFX Lite

·

fezmonkey
06-28-2010, 09:17 PM
Heater, like I said before, using linux/mono is possible in theory but no one has done it before

Baggers, blinking an LED is easier on prop because prop is made to handle low level things very well. Now try to do a real life application, like a data logger, then FEZ would be much easier. Now, FEZ can't do timing at all so generating audio or video would be impossible on FEZ. Each device has its strengths and weaknesses.

StefanL38
06-28-2010, 09:25 PM
maybe you put up your nose about that.
I was programming in Pascal and Delphi for years. And from that startingpoint it was a breeze to learn spin

best regards

Stefan

Baggers
06-28-2010, 09:33 PM
Yeah, fez, I know things have strengths and weaknesses, and sorry if my replies seem harsh, I guess I like the prop too much, maybe because, like their advert "remember when programming was fun" I really enjoy programming on the prop, it's fun, and very easy to program on, and I guess I like spin more as a language than any of the C variants :)

btw, the prop can be a data logger, and a very good one too, and it would be very easy to write one for the prop, taking measurements from the pins ( either I2C to a device, or SPI, or ADC on the pins, then store to eeprom or serial to PC or to SD, or even to a TV display, the prop can do it easily, and it would be very quick to prototype, so maybe your example wasn't the best to use, but I agree, they are separate chips, with separate target customers.

and like your gameo you use them both to their strengths, the prop for displaying an image on the tv, and the arm chip for writing the game logic, and using the usb ability of the arm for loading from SD or USBkey and sending to the prop.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
http://www.propgfx.co.uk/forum/·home of the PropGFX Lite

·

fezmonkey
06-28-2010, 09:53 PM
Yes with combining both, prop and FEZ, I see soooo many possibilities! The only down side now is the resolution I have. 128x96 is not really a lot of pixels! If I could have 256x192 then that would be just terrific. The problem is I need double buffering to eliminate flickering.

Maybe a future prop will have 64K of ram?

Adding external RAM is not an option here.

Baggers
06-28-2010, 10:08 PM
you can have a higher res than 128x96, that is just for the 256 colour bitmap, or 16colour bitmap with room for double buffering.
the beauty of the prop, is you can work the display driver to your needs, since you're using it for a gameo, then why don't you do a 256x192 or 320x200 but have a character mapped display with sprites on?

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
http://www.propgfx.co.uk/forum/·home of the PropGFX Lite

·

fezmonkey
06-29-2010, 02:39 AM
Like you said, it is propeller so driver can change anytime. This wouldn't stop the project from moving forward with the resolution we have now.

I want to see a game running with USB joystick and loading levels/resources from SD card or USB thumb drive.....very soon now!

Baggers
06-29-2010, 02:56 AM
will look forward to the posted video :D

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
http://www.propgfx.co.uk/forum/·home of the PropGFX Lite

·

Dr_Acula
06-29-2010, 09:31 PM
Just testing out my audio circuit with this simple bit of spin (and the latest AYcog object)



CON _clkmode = xtal1 + pll16x
_xinfreq = 5_000_000

SDPins = 0
audioR = 0
audioL = 24
' playRate = 80_000_000/50
VAR
byte buffer[25]
byte filename[18]

long fileNumber
long nrOfTunes

OBJ
AY : "AYcog_V0-16"
' SD : "fsrw"

PUB Main | AYregisters, i, j, value, playRate

AYregisters := AY.start( audioR, audioL )

playRate := 5
repeat
waitcnt(cnt + 80_000_000/playrate)
repeat i from 0 to 15
value := (?j)&255
if i>9 and i<13
value &= 31
byte[AYregisters + i] := value




All working great. My little LM386 is working fine. Not even getting warm and it is quite loud into a 4" speaker.

I haven't been able to do the ym files yet as I'm using fat32 sd cards so I need to port the fsrw part to KyeDOS. Maybe add the audio files to a menu somehow as well.

This is so nifty!

All retro emulations are going to really benefit from this audio.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.smarthome.viviti.com/propeller (http://www.smarthome.viviti.com/propeller)

lonesock
06-29-2010, 10:10 PM
FSRW 2.6 does handle FAT32 (support for FAT32 was added almost a year ago [8^). Kye's code does as well, with the added benefit of subdirectories.

Jonathan

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
lonesock
Piranha are people too.
(geek humor escalation => "There are 100 types of people: those who understand binary, and those who understand bit masks")

Dr_Acula
06-30-2010, 06:13 AM
Thanks lonesock - I didn't know that and it will make writing an audio demo a lot easier! Cheers.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.smarthome.viviti.com/propeller (http://www.smarthome.viviti.com/propeller)

Ahle2
04-20-2011, 05:43 PM
AYcog version 0.6 is in the OBEX.

Ahle2
05-17-2012, 07:55 PM
AYcog version 0.8 is in the OBEX.

Changes:
- Increased volume table accuracy
- Increased noise accuracy
- Opmtimized code a little bit

rogloh
01-01-2013, 12:59 PM
Hi Ahle2,

I was reading through your AY-3-891X emulator code in the OBEX and was thinking it might be possible to customize it to get some simple 8 bit PCM capabilities out of it as well as the AY-3-891X audio. This could be achieved by repurposing the currently unused 8 bit I/O port A and port B registers to conveniently pass in the 8 bit PCM values for each channel. They could then mixed with the existing (mono) AY-3-891X source separately for each channel. If this really is possible I think it would be a pretty cool extra feature because it then lets you do AY-3-891X music/sound fx AND PCM simultaneously on the same output pin without needing additional hardware resources. That is exactly the type of capability I am looking for in my application right now.

Below is a further description of what I am contemplating. Please understand that I haven't tried it out yet so I am not sure if this overall idea even fits in with your current duty cycle modulation scheme or not. But I am thinking of trying it once I get time with a proper test setup in place. You might also be interested in attempting this too, or shoot it down as being fundamentally incompatible or identify other problems with PCM data formats etc. I'm still hoping it's achievable.

Description of PCM extensions:

When reading all the AY registers, you would read and save off the last two I/O port values in the 16 byte register block as the initial DAC values for each channel. You would need to shift up these two 8 bit PCM values into the MSBs of two 32 bit words (which I called dacA and dacB) to be mixed later. If there is no PCM value needed to be added, the caller would simply leave a zero in these AY registers and it would have no effect.

In the register reading code block, here is the new code in red for example. Further rearranging could optimize hub op timing of later wrByte. This is just to show the idea.



rdbyte envelopePeriod, tempValue ' reg 11
add tempValue, #1
shl noisePeriod, #20
rdbyte temp1, tempValue ' reg 12
shl temp1, #8
or envelopePeriod, temp1 wz
if_z mov envelopePeriod, half_period ' 0 == half the period of 1
if_nz shl envelopePeriod, #16
add tempValue, #2
rdword dacA, tempValue ' regs 14 and 15 hold DAC A and DAC B samples
sub tempValue, #1
mov dacB, dacA
rdbyte envelopeShape, tempValue ' reg 13
movd oscValues, enableRegister
shl dacA, #24 ' align data to MSBs
shr dacB, #8
shl dacB, #24 ' align data to MSBs



At the mixer stage you would add the existing (mono) AY sample output separately to the two DAC output value accumulators and then write these to the FRQ register used for that channel.

In the sample mixing code block, here is the new code in red for example


mixer mov r1, val31bit ' DC offset
add r1, out1
add r1, out2
add r1, out3
add dacA, r1
add dacB, r1
waitcnt waitCounter, sampleRate ' Wait until the right time to update
mov FRQA, dacA ' the PWM values in FRQA/FRQB
mov FRQB, dacB '
jmp #mainLoop


Conveniently it seems the code has already accounted for up to 4 channels in the MAX_AMPLITUDE constant even though there are only 3 channels used today, so no overdriving should happen with the extra PCM component summed in as I understand it.


MAX_AMPLITUDE = float(POSX / 4) ' maxInt32value / numberOfChannels (this makes room for maximum "swing" on all channels)


Also the two new DAC values are also required to be stored in the COG's memory


noiseMSB long 1 << NOISE_MSB
noiseTap long NOISE_TAP
sampleRate long 0
dacA long 0
dacB long 0
freqRef long 10<<20



I counted up the instructions in your existing code (v0.8) and it is getting tight at 125kHz (there's not a lot of free cycles left perhaps ~32-40 worth or so if I counted right) but I think at least 6 more instructions can also be gained by inlining the getAmplitude subroutine that is called 3 times when determining the amplitude of each channel which then removes the 6 call/return instruction operation overheads. With that there are maybe 56 clock cycles overall to play with. Probably good to leave a few spare for slight hub op timing variation each iteration.

I think I added about 36 clock cycles with the above code if the read operation is strategically placed so it might still be possible to squeeze it in and keep it clocking at 125kHz. :thumb:

DAC Synchronization issues:

Now one could always choose to write the two PCM register bytes asynchronously if you had to (it probably would not sound too exceptional) but in order to properly synchronize the PCM source with the output I was thinking about toggling another pin once per sample or writing to another memory location which can be read/cleared by some other COG which feeds it PCM data at some convenient sub-multiple of the sampling rate. In my particular application for example I would like to try to run this code at 88200 Hz instead of 125kHz and probably toggle a pin every iteration to create a simple square wave interrupt signal at a rate of 44.1kHz. This would then be used for triggering an external microcontroller and/or COG to update the PCM registers in time for the next sample and consequently keeping it fed with 44.1kHz 8 bit stereo audio source data. A simple XOR of an outA port register bit would suffice for driving such an interrupt signal so only one additional instruction would be required there. Simple. Otherwise another memory address write for another COG to poll is required which would burn a few more cycles. But if sampled at 88.2kHz the cycle count would no longer be an issue when compared to operating at 125kHz.

I'm still figuring out which exact parameters in your code to change for achieving the 88.2kHz sample rate - it's quite hard for me to determine what parameters are affected by this and that is a separate question for you.

I would be very interested in hearing your thoughts on this overall idea Johannes, as well as any other people who are interested in it.

Regards,
Roger. :smile:

P.s. Separate crazy idea....there are two other bits that were related to the original I/O port direction in AY register 7. Perhaps they could also be repurposed to enable/disable AY output on each channel in the mixer stage for even finer audio output control on each channel. Also, if they are modulated at a high enough rate, it might be able to give some weird panning or tremelo effect perhaps...I will have to try that too. Could sound a bit harsh I imagine. It burns 2 more instructions in the mixer to extract the two control bits eg.


mixer mov r1, val31bit ' DC offset
add r1, out1
add r1, out2
add r1, out3
test enableRegister, #$80 wc
test enableRegister, #$40 wz
if_nz add dacA, r1
if_c add dacB, r1
waitcnt waitCounter, sampleRate ' Wait until the right time to update
mov FRQA, dacA ' the PWM values in FRQA/FRQB
mov FRQB, dacB '
jmp #mainLoop

rogloh
01-01-2013, 01:20 PM
Just realized I probably have made the amplitude too large for the PCM audio component in the above sample code. Would want to shift it up a couple of bits less (and sign extend) when aligning within the 32 bit word so as not to overdrive the output.

Ahle2
01-01-2013, 01:51 PM
Of course this is possible to do. And I do think it's a very nice feature to add.
It won't be an AY-3-19010 though, so I will not include it in the official code.
Feel free to make a fork or hack or whatever you want to do! :)

rogloh
01-01-2013, 11:33 PM
Great, I am going to give it a try when I get a chance and see if it works and how it sounds. Thanks Ahle2.

Luckily I do not need true AY-3-8910 compliance as you can tell by the weird hacks I am planning here, but it should still make for a very handy sound engine with very low hub RAM usage once loaded. I like it. :smile:

Cheers,
Roger.

rogloh
01-02-2013, 05:20 AM
So I soldered up a simple audio interface on my prop demo board and hacked about with the code today. I got some 8 bit WAV samples to play and mix in with the AY-3-8910 sound effects simultaneously and I am quite happy with the end result. Spin was not working quite right with a waitcnt (too slow) but worked okay once I added the extra output pin toggle at the sampling rate in the AY COG and got the spin code waiting on this before updating the sample.

In case anyone wants to do something similar, the code I provided above works okay, but it may be safer to also add these two sar instructions to reduce the modulation of the PCM source so as not to overload the accumulator with all four sources adding into it if that bothers you.

shl dacA, #24
sar dacA, #2
shr dacB, #8
shl dacB, #24
sar dacB, #2

Also, to change the sampling rate to a value suitable for 44.1kHz and sub rate sources (I used 88.2kHz), you just need to change the following two parameters. This then keeps the AY waveform output thinking it has a 125kHz reference clock.


SAMPLE_RATE = 88_200 ' Sample rate of AYcog (125 kHz is maximum for an 80 Mhz propeller)

OSC_CORR = trunc(1.489 * PSG_FREQ) ' Relative oscillator frequency

Ahle2
01-05-2013, 09:53 AM
What came out of this? Anything to show?

rogloh
01-05-2013, 11:34 AM
Yeah well I got it to go and I was able to mix in the PCM from an 8 bit wave file. Was a bit limited by the size of HUB ram so I was only able to put small snippets of low rate WAVs into memory so it wasn't a great test but I could hear it working. Now need to hack up some SD card interface to stream larger files from that for futher audio experiments.

But another thing I tried was to merge this in with Micah's S/PDIF object and see what happens when I play some demo AY music from your AYCog demonstration code digitally through the S/DPIF buffer to my amp. Even though I believe it is properly synchronized to the S/PDIF object at 44.1kHz it is sounding somewhat distorted when I feed it into my amp via TOSLINK (Logitech Z-5500D). I mostly hear it happen when two voices are playing the melody part simultaneously. Actually I quite liked some of the distortion effects it generated - parts of it sound a bit more like an electric guitar. :cool: It also doesn't seem to be as snappy to turn on/off sounds, I hear them almost bleed into one another. Single voice sounds okay as does Micah's test synth code here http://scanlime.org/2011/04/spdif-digital-audio-on-a-microcontroller/ . I checked the max modulation depth and it is 1/4 of the 16 bit range and I was not feeding any additional PCM sources - I'd reverted to original AYCog, so that should be fine. I'd checked the source was signed two's complement and I also shifted the samples down to a subset of the range and lowered playback volumes in the AYCog code and still didn't help. It also happens the same way when I slow down the music. What is weird is the existing analog outputs (which I still output too during playback) all sounds fine and that is all driven from the S/PDIF playback rate as well. So I am guessing it is sounding like this over the digital interface because of the rather harsh (square wave) modulation going straight into the amp's DAC without any low pass filtering unlike what probably happens on the analog inputs of my amp. Luckily I kept the volume down to be kind to the speakers. Once I get the SD card setup I want to try to playback a 16 bit wave directly to make sure my S/PDIF and amp setup are all good. Ultimately I want to be able to output both analog and digitally simultaneously if possible (just using 2 COGs, keeping 6 others free for video and my PS/2 interfaces). If the square waves sound harsh I might investigate other options (maybe sine table lookups). Once I get the digital interface up and running I could always generate better sounds that way from my external micro (think MOD files), but I would quite like to use the AYCog as well for a more retro sound.

Ahle2
01-05-2013, 12:25 PM
So what exactly are you trying to achieve? External micro... mod playback.... retro sounds... video generation.... ps2 keyboard... This sounds interesting!

AYcog generates unsigned samples, so you will need to subtract 2^31 from the sample to convert it to signed.
Then it's very important that AYcog and the S/PDIF object are 100% synced and not 99.99999%. You will hear even the slightest diff.

/Johannes

rogloh
01-05-2013, 12:27 PM
Distortion fixed!! Was a stupid signed/unsigned error in the end. Once I subtracted 0x80000000 from the samples going to the SPDIF COG, the optical output now sounds just like the analog (but clearer). Excellent!

rogloh
01-05-2013, 12:44 PM
LOL, just read your last post after I wrote mine. Thanks anyway - you were indeed right. :thumb:

Well I am trying to put together a nice little retro platform just for fun to see what sort of performance I can achieve from the propeller for A/V. Right now on the propeller side I have a customized video driver working with 12 bit color and am adding audio to it as well as I/O devices. I guess a lot of people like using the prop standalone for these things but I am using it in a slightly different way as part of something else...more posts when I get further along.

Ahle2
01-05-2013, 12:52 PM
Very interesting indeed. I think you should start a new thread for your project!!

/Johannes