Sound emulation survey

Started by cpcitor, 23:21, 03 November 21

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

cpcitor

Hi! This is a survey to gather some information about behaviors of emulators with regard to sound.

Can you run the BASIC commands below on real CPCs and emulators and tell what you hear?
It's even better if you can post captures of the output.

The first is only to sanity check your setup and make sure you hear a 440Hz basic tone.
The second is the one I'm interested in.

sound 2,284,50,15 : sound 2,6,50,15

Here are my samples:

* cpcec or cpcec-plus (Linux): 1 second 440Hz tone, then one second of a different, higher pitch, tone. Attached sound_2_284_50_15_sound_2_6_50_15_cpcec.wav.bin
* caprice32 (Linux): 1 second 440Hz tone, then one second of a different, higher pitch, tone. But different!
* floooh's chips test of the tiny8bits emulator libraries:  1 second 440Hz tone, then one second of a different, higher pitch, tone. But different again! (You can try it live on https://floooh.github.io/tiny8bit/cpc.html?type=cpc464 )
* real CPC... I let you try this one.

You might be wondering why I'm asking this.

If you think you can guess why I'm asking this, your guess is welcome.

Captures from emulators and real CPCs are the most welcome of all.

It's best with attached samples. Since the forum rejects wav files, simply rename to .wav.bin and it passed.
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.

roudoudou

the crappy high pitch sound is due to aliasing/rounded index for replay

i asked Megachur to let his emulator run at higher replay rate (up to 192KHz) and it solve easily most the high frequencies replay (still not perfect but really better)
a solution for high frequencies replay at 44Khz or 48Khz may be to use sinus instead of squares and let shanon do the rest
use RASM, the best assembler ever made :p

I will survive

cpcitor

Quote from: roudoudou on 23:37, 03 November 21
the crappy high pitch sound is due to aliasing/rounded index for replay

i asked Megachur to let his emulator run at higher replay rate (up to 192KHz) and it solve easily most the high frequencies replay (still not perfect but really better)
a solution for high frequencies replay at 44Khz or 48Khz may be to use sinus instead of squares and let shanon do the rest

You're right, this is aliasing.

Still, that's not all.

Shannon does not say to replace the square with a sine, and there's no need to deviate from the chip behavior like this.

Is there any emulator out there that has a different result?
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.

eto

Quote from: cpcitor on 23:21, 03 November 21You might be wondering why I'm asking this.

Indeed - and knowing it might make help to motivate people to attach cables and record it ;-)

roudoudou

Quote from: cpcitor on 13:57, 04 November 21
Shannon does not say to replace the square with a sine, and there's no need to deviate from the chip behavior like this.
I never said that  :o
What i mean is using a sinus will keep the high frequencies clean. It's impossible with a square signal and a restitution frequency non multiple of the generator one

Moreover, the AY high frequencies looks like sinus signal because it can't do a clean square so fast  ;D

use RASM, the best assembler ever made :p

I will survive

cpcitor

#5
Reason the the survey

Quote from: eto on 15:42, 04 November 21
Indeed - and knowing it might make help to motivate people to attach cables and record it ;-)

Okay, @eto, thanks for asking. I'm considering some advanced signal processing tricks to play unusual audio on the CPC.

For an introduction of the neighboring concept, see https://en.wikipedia.org/wiki/Noise_shaping . In plain English, sending specifically crafted signals at high speed can overcome the hardware limitations in some sense.  For a crazy example not in audio but in the radio frequency range, see https://bellard.org/dvbt/ . This one is out of league, anyway.

To come back to CPC level: it's about using the phenomenon alluded to by roudoudou to our advantage: very high frequency output from the AY chip is somehow dampened.

My firsts experiments suggested that (some? nearly all?) emulators will not emulate that properly.

It would feel somehow strange to make some high quality sound output that blows everyone's mind when plyaing on a real CPC, yet happen to sound like crap on nearly all emulators.  :doh:

Hence the survey.   :)




Please try this on your emulator

I attached a screenshot of an updated listing, will give much more interesting results.

 [ You are not allowed to view this attachment ]  

And results on cpcec, caprice32, chips are attached:
 [ You are not allowed to view this attachment ]  
 [ You are not allowed to view this attachment ]  
 [ You are not allowed to view this attachment ]  

Please run the listing on your emulators, record the output and post it.

For a real CPC, recording with any device (e.g. smartphone) and sending a MP4 etc will be enough.

How to record a program with Audacity

Linux users with pulseaudio: run audacity, enable monitoring, run pavucontrol and in "Recording" tab, set ALSA plug-in[audacity]: ALSA Capture from "Monitor of [name of your sound card]".

 [ You are not allowed to view this attachment ]  

Windows users see: https://manual.audacityteam.org/man/tutorial_recording_computer_playback_on_windows.html

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.

eto

Sounds interesting. I can provide a few samples if there is no hurry. Probably over the weekend. I have a few real machines (6128 plus, 6128, 464) where I can sample the output.

andycadley

If it works on real hard, you should totally do it even if it sounds like crap on an emulator.


Stuff like this is what pushes the envelope of emulator development. Such as Chromatrons Attack on the Speccy, which relies on weird quirks in the PAL signal to generate an image. Initially didn't look right on emulators at all, but a few of the more advanced ones can now pull it off and, as a result, can do a better job of rendering all software.

Aeliss

Here a sample on Arnold https://www.cjoint.com/c/KKerLtQRdga
Some sound part are totaly missing

cpcitor

Quote from: Aeliss on 19:37, 04 November 21
Here a sample on Arnold https://www.cjoint.com/c/KKerLtQRdga
Some sound part are totaly missing

Excellent! Thanks! This is the best output so far.

Is it Arnold Emu by Kevin Thacker?
Which version of Arnold is it?
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: andycadley on 19:16, 04 November 21
If it works on real hard, you should totally do it even if it sounds like crap on an emulator.

Thanks! You're right.

It was written about the demo 8088mph for the original IBM PC of 1981 "Yes, this demo breaks all emulators"

https://www.youtube.com/watch?v=gdb3AQ14iVc

Quote from: andycadley on 19:16, 04 November 21
Stuff like this is what pushes the envelope of emulator development. Such as Chromatrons Attack on the Speccy, which relies on weird quirks in the PAL signal to generate an image. Initially didn't look right on emulators at all, but a few of the more advanced ones can now pull it off and, as a result, can do a better job of rendering all software.

Ah, yes, the trick of using composite output, like it was done on the PC https://int10h.org/blog/2015/04/cga-in-1024-colors-new-mode-illustrated/ and so often on the Apple 2, that Apple 2 computers fitted with a RGB output emulated it.

Thanks, I did not know it could be done on the Spectrum, too.
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

#11
Here are spectrum images of the emulators tested so far.

In theory one should see a hyperbolic-step shape of the first harmonic and second harmonic and nothing else.

Lots of orange bars (or worse, yellow) in the 0-1000Hz range (bottom of chart) means you hear false tones, at various heights. All 4 have it except Arnold.

Chips: high density of red all over. Plus some vertical artifacts at ~3.5 seconds, ~5.6s, ~7.9s, ~8.05s, ~9.8s.
 [ You are not allowed to view this attachment ]  

Cpcec: red all over. Cheating at period 1-5 by outputting nothing. At 5 there should be a yellow line at 12500Hz.
 [ You are not allowed to view this attachment ]  

Caprice32: blue and red "spots" all over. Better than cpcec. Cheating at period 1-4 by outputting nothing. The yellow curves are at least visually standing out somehow.
 [ You are not allowed to view this attachment ]  

Arnold: some noise, but the cleanest spectrum so far. You can see the hyperbolic shape of the first harmonic (yellow curve) and second harmonic (orange curve on top right). Spurious frequencies are much weaker and only at high frequency (2.5+ kHz).
 [ You are not allowed to view this attachment ]  

Open to other measurements, thanks!
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.

roudoudou

use RASM, the best assembler ever made :p

I will survive

eto

Schneider 6128 - early and late model
Amstrad 6128 plus
RetroVm - 2.0 beta 1 r7
https://www.dropbox.com/s/c094rb9yuquznex/soundtest.zip

Bryce

Quote from: cpcitor on 13:58, 05 November 21
Arnold: some noise, but the cleanest spectrum so far. You can see the hyperbolic shape of the first harmonic (yellow curve) and second harmonic (orange curve on top right). Spurious frequencies are much weaker and only at high frequency (2.5+ kHz).
 

Open to other measurements, thanks!

Just for correctness. The orange curve is the third harmonic not the second: 1st = Fundamental frequency (f), 2nd harmonic = 2f, 3rd harmonic =3f and so on.

Bryce.

cpcitor

#15
Quote from: roudoudou on 16:18, 05 November 21
Here is captures of CPCEmu_Power Linux
http://www.roudoudou.com/export/cpc/temp/cpcemu_power_44Khz.wav (emulator and recording @44KHz)

http://www.roudoudou.com/export/cpc/temp/cpcemu_power_192_to_44Khz.wav (emulator @192Khz output + record @44KHz)
http://www.roudoudou.com/export/cpc/temp/cpcemu_power_192Khz.wav (emulator and recording @192KHz)

Can you describe the recording setup a bit better?

Hearing them, I find them between cpcec and caprice32, closer to caprice32. Visually they look closer to cpcec.  :-\

Here are the spectrums (spectra?) in same order:

 [ You are not allowed to view this attachment ]  
 [ You are not allowed to view this attachment ]  
 [ You are not allowed to view this attachment ]  
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: eto on 16:21, 05 November 21
Schneider 6128 - early and late model
Amstrad 6128 plus
RetroVm - 2.0 beta 1 r7
https://www.dropbox.com/s/c094rb9yuquznex/soundtest.zip

Ah, a real beep from a real, CPC! That's refreshing to hear!
No spurious frequencies, as expected.

Oh, RetroVm is really good!
I reproduced it here, and it performs proper low-pass filtering! Youhoo! Congratulations to authors of RetroVirtualMachine!

Here are the spectrums (spectra?) in same order:

 [ You are not allowed to view this attachment ]    [ You are not allowed to view this attachment ]    [ You are not allowed to view this attachment ]    [ You are not allowed to view this attachment ]  

Quote from: Bryce on 17:12, 05 November 21
Just for correctness. The orange curve is the third harmonic not the second: 1st = Fundamental frequency (f), 2nd harmonic = 2f, 3rd harmonic =3f and so on.

Bryce.


Oh, you're right, I was misusing the terminology.
It's the second non-null in a theoretically perfect square wave, but since it's a 3f it's the third harmonic.
Thanks @Bryce.

Oh, errrm, it was a mistake on purpose. To check if you were listening.  ;)

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.

roudoudou

Quote from: cpcitor on 00:25, 06 November 21
Can you describe the recording setup a bit better?
Hearing them, I find them between cpcec and caprice32, closer to caprice32. Visually they look closer to cpcec.  :-\
i simply run the emulator and record with arecord (PulseAudio PCM utilisant ALSA)
note that the last WAV is mono and should be cleaner that the second one

use RASM, the best assembler ever made :p

I will survive

BSC

Quote from: cpcitor on 17:27, 04 November 21I'm considering some advanced signal processing tricks to play unusual audio on the CPC.

Great topic, looking forward to hearing your tricks at play. Also thanks for the additional links, I am always happy to learn more about (the endless realms of) digital audio.

cpcitor

Quote from: BSC on 01:06, 06 November 21
Great topic, looking forward to hearing your tricks at play. Also thanks for the additional links, I am always happy to learn more about (the endless realms of) digital audio.

Don't hold your breath, though. :-)

This is the video that got me inspired in believing that maybe something is possible https://wiki.xiph.org/Videos/Digital_Show_and_Tell (or go straight to the video https://www.xiph.org/video/vid2.shtml ).

A number of obstacles exist between the idea of something and an implementation within the constraints of the CPC.

I don't promise anything. You can pretend there's no hope, to avoid any disappointment.

And if the only gain of this thread is that mainstream emulators "align to the top", that is get a sound much closer to a real CPC sound, it's already worth it. :-)

In the meantime you can enjoy this tune
https://www.youtube.com/watch?v=qgjRwBQzJss apparently playing on the YM2149 variant of the chip, on a Atari ST, a chip very similar to our AY8912 ( https://maidavale.org/blog/ay-ym-differences/ ). The CPC probably cannot do exactly this due to slower clocks, but I still think there are some things to explore.


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.

roudoudou

Quote from: cpcitor on 00:30, 06 November 21
Oh, RetroVm is really good!
I reproduced it here, and it performs proper low-pass filtering! Youhoo! Congratulations to authors of RetroVirtualMachine!
RetroVm has a very bad replay with SID sounds. This may be due to an overall bad emulation, but hey, as we dont know what is inside the emulator... can state about it  ;D
use RASM, the best assembler ever made :p

I will survive

cpcitor

Quote from: roudoudou on 10:25, 07 November 21
RetroVm has a very bad replay with SID sounds. This may be due to an overall bad emulation, but hey, as we dont know what is inside the emulator... can state about it  ;D

RetroVM can emulate a SID? And even so, this does not affect AY emulation, right?
That said, I agree it's closed source so it's evil  :o.

Anyway, capture from RetroVm and show waveform in e.g. audacity, it shows the Gibbs phenomenon that typically results from low pass filtering.
So, it sounds like low pass filtering, it looks like low pass filtering, and it is exactly what is needed, so ... it would be even better open-sourced. ;-)

 [ You are not allowed to view this attachment ]  

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.

megachur

Quote from: cpcitor on 15:31, 06 November 21
And if the only gain of this thread is that mainstream emulators "align to the top", that is get a sound much closer to a real CPC sound, it's already worth it. :-)

In the meantime you can enjoy this tune
https://www.youtube.com/watch?v=qgjRwBQzJss apparently playing on the YM2149 variant of the chip, on a Atari ST, a chip very similar to our AY8912 ( https://maidavale.org/blog/ay-ym-differences/ ). The CPC probably cannot do exactly this due to slower clocks, but I still think there are some things to explore.
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 ?

Secondly : this youtube video have very bad sound... and 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

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 !



roudoudou

Quote from: cpcitor on 01:06, 08 November 21
RetroVM can emulate a SID? And even so, this does not affect AY emulation, right?
That said, I agree it's closed source so it's evil  :o .

Anyway, capture from RetroVm and show waveform in e.g. audacity, it shows the Gibbs phenomenon that typically results from low pass filtering.
So, it sounds like low pass filtering, it looks like low pass filtering, and it is exactly what is needed, so ... it would be even better open-sourced. ;-)


i'm talking about some SID sounds a CPC or a Plus can do* with FAST volume switching. Timing accuracy is more important than if you play a music with a 50Hz player routine. So yes, global emulation may change the sound replay ;)

*Like CRTC3 demo or KillMax demo

use RASM, the best assembler ever made :p

I will survive

cpcitor

Quote from: roudoudou on 09:02, 08 November 21
i'm talking about some SID sounds a CPC or a Plus can do* with FAST volume switching. Timing accuracy is more important than if you play a music with a 50Hz player routine. So yes, global emulation may change the sound replay ;)

Okay, RetroVm might have nice output smoothing but not respect timings, or compute too many oscillations assuming that AY registers did not change, which is not always true, will go unnoticed in most cases and totally destroy some effects. Is that what you meant?

Quote from: roudoudou on 09:02, 08 November 21
*Like CRTC3 demo or KillMax demo

Nice demos!
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