News:

Printed Amstrad Addict magazine announced, check it out here!

Main Menu
avatar_cpcitor

Sound emulation survey

Started by cpcitor, 22:21, 03 November 21

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

cpcitor

Quote from: megachur on 07:38, 08 November 21
Firstly : Yes it's a good idea but what do you show with this analysis ? that some emulators are using filter and others not !? what do you use to record the sound of the real hardware on amstrad cpc !? using stereo cable and a very, very good sound card without filter ?

The goal in this thread is to find emulator(s) that remain faithful to the original machine even when changing AY registers extremely often.
That said, I just switched to using real CPCs because, well, I believe they behave exactly like real CPCs. No aliasing at all, no extraneous frequencies whatsoever, and I'm pretty certain other real CPCs will perform the same.  ;D

Quote from: megachur on 07:38, 08 November 21
Secondly : this youtube video have very bad sound...

What do you mean? How is it bad?

Quote from: megachur on 07:38, 08 November 21and yes YM2149 (2Mhz) and AY8912-2 (1Mhz) are very similar.
see this source for the real hardware analysis done years before for mame emulator :https://github.com/mamedev/mame/blob/master/src/devices/sound/ay8910.cpp

Extremely interesting link. I had read that a complete chip analysis was performed years ago, this one states interesting facts. Things like "Careful studies of the chip output prove that the chip counts up from 0 until the counter becomes greater or equal to the period. This is an important difference when the program is rapidly changing the period to modulate the sound. This is worthwhile noting, since the datasheets say, that the chip counts down."

Quote from: megachur on 07:38, 08 November 21
The conversion of atari st songs have allready done some year ago.... the first one have been done by Longshot if I remember correctly : see https://www.cpc-power.com/index.php?page=detail&num=7799.
Most of them here : https://www.cpc-power.com/index.php?page=staff&lenom=Transfert%20Atari%20ST

It's simple : convert the 68000 code to z80 code then divide frequencies to have correct sound on 1Mhz AY !

Well, if dividing periods does not cause too high approximation (small periods), and if the original player on the ST did not access the registers so fast that the CPC can't keep up. For music the approximation feels like it should be okay. For sampled speech, maybe not so well.
Had a CPC since 1985, currently software dev professional, including embedded systems.

I made in 2013 the first CPC cross-dev environment that auto-installs C compiler and tools: cpc-dev-tool-chain: a portable toolchain for C/ASM development targetting CPC, later forked into CPCTelera.

cpcitor

#26
This test:

for p=2 to 25 : sound 2,p,50,15 : next

can easily be overlooked but it is a demanding test. Passing it very well is not obvious. It only tests whether the "misalignment" between PSG frequency (125kHz base oscillator) and audio frequency output (typically 44.1kHz or 48kHz) are well handled. This is a signal processing issue, not an emulation issue.
Had a CPC since 1985, currently software dev professional, including embedded systems.

I made in 2013 the first CPC cross-dev environment that auto-installs C compiler and tools: cpc-dev-tool-chain: a portable toolchain for C/ASM development targetting CPC, later forked into CPCTelera.

zhulien

The sound chip isn't the only way the CPC can make music.  You can also click the tape motor on and off fast on a 464.  I don't know if you can 'control it' but, has anyone tried to control the faint buzzing of the z80 you hear at night when you do certain tasks?


If a beeper on a spectrum can sound like this:   
https://www.youtube.com/watch?v=L4LSHnMhFPU


What is the technical reason that 1 sound channel on the AY cannot simulate a spectrum's beeper as per above?


(Interesting technical page about how spectrums can achieve multichannel sound using a beeper
  https://www.gamejournal.it/the-sound-of-1-bit-technical-constraint-as-a-driver-for-musical-creativity-on-the-48k-sinclair-zx-spectrum/?fbclid=IwAR23eyQmlrxH1Th0DB7-hZaeSF0K1qOg7hBpUBeesxgVedXpd51pO_7q_BA )

megachur

#28
Quote from: cpcitor on 08:46, 08 November 21

What do you mean? How is it bad?

Just hear it on the real Atari ST and you will understand what I mean ! Even some Atari ST emulator feature no right 2Mhz YM emulation...

Also use a good stero audio headphone with correct or more than 20Hz-20KHz if you can hear it ;-)
https://www.youtube.com/watch?v=WoPWyXsD81k!

BSC

Quote from: zhulien on 17:16, 10 November 21What is the technical reason that 1 sound channel on the AY cannot simulate a spectrum's beeper as per above?

I have done some experiments using the envelope generator, they are on soundcloud:

https://soundcloud.com/betasoftcologne/4bit-sweeping-demo

https://soundcloud.com/betasoftcologne/cocio-and-finsprit-6-channel-preview

I think there are a couple of reasons why the sound of the beeper engines can not (easily) be reproduced on a CPC using the AY:

1. Much slower access to the sound chips registers, yielding a lower max replay frequency
2. I believe the beeper, even though it is programmed in a digital way, i.e. only 0 or 1 is possible, does in fact work very much like an analog(ue) device, the hardware geeks here might be able to say if I am wrong or elaborate further, but I think if for example you toggle from 0 to 1, then hold for a very short amount of time before toggling back from 1 to 0, the beeper (which is a tiny speaker that is directly connected to port &fe) will not have fully moved to its maximum displacement, but only a fraction of that, depending on the amount of time 1 was active.

I was planning to make more experiments, like manipulating a single volume register directly instead of going through the envelope generator (that was done purely out of curiosity) or actually using the tape port (port &f5) which might result in more speccy-like, albeit really delicate, sounds.



** My SID player/tracker AYAY Kaeppttn! on github **  Some CPC music and experiments ** Other music ** More music on scenestream (former nectarine) ** Some shaders ** Some Soundtrakker tunes ** Some tunes in Javascript

My hardware: ** Schneider CPC 464 with colour screen, 64k extension, 3" and 5,25 drives and more ** Amstrad CPC 6128 with M4 board, GreaseWeazle.

cpcitor

Quote from: zhulien on 17:16, 10 November 21
The sound chip isn't the only way the CPC can make music.  You can also click the tape motor on and off fast on a 464.  I don't know if you can 'control it' but, has anyone tried to control the faint buzzing of the z80 you hear at night when you do certain tasks?

A CPC can control the motor or tape output faster than the PSG. Not sure it can even make interesting sounds without damaging hardware long-term.

Quote from: zhulien on 17:16, 10 November 21
If a beeper on a spectrum can sound like this:   
https://www.youtube.com/watch?v=L4LSHnMhFPU

Excellent use of the Spectrum hardware!

Quote from: zhulien on 17:16, 10 November 21
What is the technical reason that 1 sound channel on the AY cannot simulate a spectrum's beeper as per above?

You answer later, I answer to that below.

Quote from: zhulien on 17:16, 10 November 21
(Interesting technical page about how spectrums can achieve multichannel sound using a beeper
  https://www.gamejournal.it/the-sound-of-1-bit-technical-constraint-as-a-driver-for-musical-creativity-on-the-48k-sinclair-zx-spectrum )

Interesting article with many references. Thanks for posting.

Quote from: BSC on 23:06, 10 November 21
I think there are a couple of reasons why the sound of the beeper engines can not (easily) be reproduced on a CPC using the AY:

1. Much slower access to the sound chips registers, yielding a lower max replay frequency
2. I believe the beeper, even though it is programmed in a digital way, i.e. only 0 or 1 is possible, does in fact work very much like an analog(ue) device, the hardware geeks here might be able to say if I am wrong or elaborate further, but I think if for example you toggle from 0 to 1, then hold for a very short amount of time before toggling back from 1 to 0, the beeper (which is a tiny speaker that is directly connected to port &fe) will not have fully moved to its maximum displacement, but only a fraction of that, depending on the amount of time 1 was active.

I agree with 1. Also, when an effect requires changing multiple registers, the delay between those can produce unwanted sounds (or even silence) in the meantime. Delay is minuscule for usual music on the CPC, but can limit what effects are possible and the extent of those that remain possible.

Note sure I agree with 2 as an argument. First, is the beeper on the CPC very different from what can be plugged on a spectrum?

Let's admit the speaker will not reach maximum displacement, but so what ?
Let's rephrase.
The speaker provides sound by pushing or pulling air.
Effects of high speed bit flipping put the speaker closer to a not saturated but linear regime, where frequency domain analysis provides hints.
In other words, at high base frequency, the harmonics will get dampened, right.
At which frequency does this happen?
To get a hint, we'd like to guess the range of frequencies the speaker can provide. Easiest is to ask what frequencies are emitted, disregarding if those are harmonics or even the fundamental.
The answer is : above many kHz, as people report hearing sound from the CPC even with periods as small as 5.
This is why those musics on the spectrum sound scratchy, and on the CPC, too.

But all of this does not explain IMHO why the beeper engines can not be easily reproduced on the CPC.

I would rather say: with one bit-banging output, the Spectrum developers had no choice but to explore what happens when varying delays between highs and lows.

The CPC's AY chip can modulate while the Z80 does other work, but with less control (especially no PWM), and got people accustomed to that.

In some sense the CPC has some unexplored potential, yet how that can be combined feels a tough space to explore.

Quote from: BSC on 23:06, 10 November 21
I was planning to make more experiments, like manipulating a single volume register directly instead of going through the envelope generator (that was done purely out of curiosity) or actually using the tape port (port &f5) which might result in more speccy-like, albeit really delicate, sounds.

On a CPC you can control the tape signal output "very" quickly (Z80 OUT takes 'µs or 1/250000s on the CPC). About 5 times quicker than the fastest PSG access.

So, I recently had the idea of a "tape demo". You put a cassette in your CPC464, press "record", run the code, you hear a low volume music while tape records. Then you put the cassette in a regular player and it plays something "remarkable".
(If you're sad enough ;) to own a CPC 6128, you can plug a cable on the DIN and either connect that to you audio amplifier or to a tape recorder.)

Quote from: BSC on 23:06, 10 November 21
I have done some experiments using the envelope generator, they are on soundcloud:

https://soundcloud.com/betasoftcologne/4bit-sweeping-demo

https://soundcloud.com/betasoftcologne/cocio-and-finsprit-6-channel-preview

Interesting. Could you share what parameters are set and are changing in each section?
I can't even say if the sequence of sections repeat periodically or not.
Had a CPC since 1985, currently software dev professional, including embedded systems.

I made in 2013 the first CPC cross-dev environment that auto-installs C compiler and tools: cpc-dev-tool-chain: a portable toolchain for C/ASM development targetting CPC, later forked into CPCTelera.

cpcitor

Quote from: megachur on 17:53, 10 November 21
Just hear it on the real Atari ST and you will understand what I mean ! Even some Atari ST emulator feature no right 2Mhz YM emulation...

I have no ST to try that.

I believe you gladly, about the limited emulation.

Best if you can be more specific, or provide a recording of the same tune.
Had a CPC since 1985, currently software dev professional, including embedded systems.

I made in 2013 the first CPC cross-dev environment that auto-installs C compiler and tools: cpc-dev-tool-chain: a portable toolchain for C/ASM development targetting CPC, later forked into CPCTelera.

cpcitor

You will find below audio and spectrum recorded from a real CPC6128 by putting a smartphone microphone in front of the CPC speaker.

From a signal processing perspective it's bad to record like this because the signal is "dirty". In this case it allows to get hints about the speaker bandwidth.

I took care of recording in uncompressed wav format. My first try was with an app that compresses to m4a, and this resulted in subtle yet interesting 'holes' in the spectrum (this isn't related to retrocomputing, but I may share if some of you are interested).

To be fair, consumer grade audio recording equipment might not be a good idea for subtle sound analysis, so one should really watch out for strange things.

Analysis of diagram

Overall there is a pattern of continuous horizontal lines.
You can see that it continue after 13.27s, when no sound is emitted and the AY chip is at rest. Because it is continues the same all the time, it is not a consequence of the changing signals and so not aliasing of those frequencies. Since I was in a relatively quiet room but still in a city, it represents the sum of the city background noise plus the continuous background noise a CPC speaker emits.
I guess that the apparently changing strength of it reflects the automatic gain control of the sound recording.
Let's ignore it.

Let's jump to the sound at 12.5s, period 4095. It should have a visible fundamental at 125000/4095 = 30Hz, yet spectrum actually peaks at around 880Hz, and fades to the low frequencies. Nearly nothing below ~100Hz. This shows that the speaker does not let bass frequencies through. This could be analyzed further to establish a Bode diagram of the CPC speaker. Has someone done this already? @Targhan how does the "Emulate CPC internal speaker" option in Arkos Tracker 2 work?

So, what else do we see? Fundamental frequency, very loud (lowest curve). Third harmonics as expected (third curve), and fifth (top right lonely bar), but also second and fourth harmonics (second and fourth curves).

No specific frequency at periods 2, 3 and 4.
Things go on smoothly until period 12 (6.2 seconds and before).

Something strange at period 13: there seem to be energy at frequencies below 300Hz, which does not happen at other times. Perhaps some artifact in the recording rig? Spurious frequencies at periods 14, 15 and 16 (6.5s to 8s).
Then relatively clean spectrum upwards.

So, overall we see how a real spectrum off a real CPC6128 speaker looks like.

Now, emulators that aim at accuracy should properly handle the conversion from the 125kHz-based AY to the app sampling frequency. I'm considering providing example code for one of the emulators, properly commented so as to be reusable by other emulators. Comments welcome.

Had a CPC since 1985, currently software dev professional, including embedded systems.

I made in 2013 the first CPC cross-dev environment that auto-installs C compiler and tools: cpc-dev-tool-chain: a portable toolchain for C/ASM development targetting CPC, later forked into CPCTelera.

Aeliss

#33
Quote from: cpcitor on 18:58, 04 November 21xcellent! Thanks! This is the best output so far.

Is it Arnold Emu by Kevin Thacker?
Which version of Arnold is it?

It's a modified version https://www.cpcwiki.eu/forum/emulators/another-version-of-arnold-emulator/ but yes, the core is almost the same.

BSC

#34
Quote from: cpcitor on 10:29, 11 November 21
Note sure I agree with 2 as an argument. First, is the beeper on the CPC very different from what can be plugged on a spectrum?

Let's admit the speaker will not reach maximum displacement, but so what ? Let's rephrase.The speaker provides sound by pushing or pulling air.
Effects of high speed bit flipping put the speaker closer to a not saturated but linear regime, where frequency domain analysis provides hints.
In other words, at high base frequency, the harmonics will get dampened, right. At which frequency does this happen?
To get a hint, we'd like to guess the range of frequencies the speaker can provide. Easiest is to ask what frequencies are emitted, disregarding if those are harmonics or even the fundamental.
The answer is : above many kHz, as people report hearing sound from the CPC even with periods as small as 5.
This is why those musics on the spectrum sound scratchy, and on the CPC, too.
But all of this does not explain IMHO why the beeper engines can not be easily reproduced on the CPC.
I would rather say: with one bit-banging output, the Spectrum developers had no choice but to explore what happens when varying delays between highs and lows.
The CPC's AY chip can modulate while the Z80 does other work, but with less control (especially no PWM), and got people accustomed to that.
In some sense the CPC has some unexplored potential, yet how that can be combined feels a tough space to explore.

I am not sure if I follow you on what you wrote concerning frequencys and harmonics. Care to elaborate?

Anyway, there is no "beeper" in the CPC as is in the Spectrum. The beeper I was referring to is the envelope generator of the AY.
Then, of course, an external AY can be plugged to the olden Spectrums with only a beeper (16k and 48k versions), but in any case all spectrums have the beeper.
But I guess you already knew all that.

I agree with your sentiment on the explorations Spectrum delevopers had to do. But I also think that much more is possible than what I have shown in my demos.
I might continue my experiments soonish, as I could not really work on my CPC related stuff since last summer. But that's about to change.


Quote from: cpcitor on 10:29, 11 November 21
On a CPC you can control the tape signal output "very" quickly (Z80 OUT takes 'µs or 1/250000s on the CPC). About 5 times quicker than the fastest PSG access.

So, I recently had the idea of a "tape demo". You put a cassette in your CPC464, press "record", run the code, you hear a low volume music while tape records. Then you put the cassette in a regular player and it plays something "remarkable".
(If you're sad enough  to own a CPC 6128, you can plug a cable on the DIN and either connect that to you audio amplifier or to a tape recorder.)

Yes! I think the tape "beeper" is a good approximation of the Spectrum one. Have you already tried this approach?


Quote from: cpcitor on 10:29, 11 November 21
Interesting. Could you share what parameters are set and are changing in each section?
I can't even say if the sequence of sections repeat periodically or not.

Regarding this:

https://soundcloud.com/betasoftcologne/4bit-sweeping-demo

I think it consists of 4 virtual oscillators which trigger a re-start of the envelope generator shape every time one of the oscillators
"transitions" from low to high or vice versa. The envelope shapes vary throughout the track, every 3 seconds, but I don't recall
which exact shapes were used at what time, but all of them were of the non-repeating type. And the oscillators were only a few
hertz apart each, like 400, 403, 406 and 409, to get a lot of beating.

And regarding this one:

https://soundcloud.com/betasoftcologne/cocio-and-finsprit-6-channel-preview

This is basically the same as above, but with 4 oscillators for the bass and 2 for the lead and I think the frequency difference was
even smaller, like 1 Hz apart.
** My SID player/tracker AYAY Kaeppttn! on github **  Some CPC music and experiments ** Other music ** More music on scenestream (former nectarine) ** Some shaders ** Some Soundtrakker tunes ** Some tunes in Javascript

My hardware: ** Schneider CPC 464 with colour screen, 64k extension, 3" and 5,25 drives and more ** Amstrad CPC 6128 with M4 board, GreaseWeazle.

cpcitor

Quote from: BSC on 21:18, 14 December 21
I am not sure if I follow you on what you wrote concerning frequencys and harmonics. Care to elaborate?

Probably yes, but not quickly, I'll have to re-read and think it again.

Quote from: BSC on 21:18, 14 December 21
Anyway, there is no "beeper" in the CPC as is in the Spectrum. The beeper I was referring to is the envelope generator of the AY.

The "beeper" I was referring to is the mechanical speaker:

Quote from: BSC
beeper (which is a tiny speaker that is directly connected to port &fe)

... and yes, on the CPC it's connected to the AY chip, not a I/O port close to the CPU.

Quote from: BSC
Yes! I think the tape "beeper" is a good approximation of the Spectrum one. Have you already tried this approach?

It's been only a thought experiment so far.
Notice that if you record on tape, the smoothing effect will come from the tape frequency response, which will be different from the speaker frequency response.

Quote from: BSC
Regarding this:

https://soundcloud.com/betasoftcologne/4bit-sweeping-demo

I think it consists of 4 virtual oscillators which trigger a re-start of the envelope generator shape every time one of the oscillators
"transitions" from low to high or vice versa. The envelope shapes vary throughout the track, every 3 seconds, but I don't recall
which exact shapes were used at what time, but all of them were of the non-repeating type. And the oscillators were only a few
hertz apart each, like 400, 403, 406 and 409, to get a lot of beating.

And regarding this one:

https://soundcloud.com/betasoftcologne/cocio-and-finsprit-6-channel-preview

This is basically the same as above, but with 4 oscillators for the bass and 2 for the lead and I think the frequency difference was
even smaller, like 1 Hz apart.

Thanks for the explanations. I'll have to take time to read and listen carefully.

Thank you for your feedback.
Had a CPC since 1985, currently software dev professional, including embedded systems.

I made in 2013 the first CPC cross-dev environment that auto-installs C compiler and tools: cpc-dev-tool-chain: a portable toolchain for C/ASM development targetting CPC, later forked into CPCTelera.

Powered by SMFPacks Menu Editor Mod