Oric's 8912 volume scale

Probably the most technical forum around. It does not have to be coding related, or assembly code only. Just talk about how you can use the AY chip to do cool sounding things :)
User avatar
meynaf
1st Star Corporal
Posts: 14
Joined: Mon Jul 18, 2016 6:37 pm
Location: Lyon (France)
Contact:

Re: Oric's 8912 volume scale

Post by meynaf »

Godzil wrote: No it's not the same, channel A is outputing a 440Hz square wave for exemple, and B & C are forced at 1V, you will have a 1V (full scale) square wave. If B and C are forced at 0V (which is more likely IRL) it will oscillate between 0 and 0.3333V

It's the same things as connecting AA battery in parallel, the voltage is not adding, you are not going to have 4.5V by doind that, but only 1.5V (or less if they don't have the same voltage)
From the formula you gave it is the same. It's just that instead of merely adding, an average is made. However it's like dividing by 3 and then adding. It's still a sum at the end.
So your three 1.5V AA batteries can be looked like three 0.5V ones, with added voltage. If not, i'm more and more confused :?

Godzil wrote: For the LM386, to know at which level it is going to saturate, just look at the schematics and calculate the amplifier gain (too late for me here to do that)
I don't have the required knowledge to do that (more or less noob at electronics).
User avatar
Chema
Game master
Posts: 3013
Joined: Tue Jan 17, 2006 10:55 am
Location: Gijón, SPAIN
Contact:

Re: Oric's 8912 volume scale

Post by Chema »

The thing is that you are connecting voltage sources in parallel, not in series. I am not sure for the output of the AY, but if they were batteries the thing is that if they are connected in series their voltages add up, but amperage is the same. If connected in parallel they voltage is the same and their amperage adds up.

http://www.zbattery.com/Connecting-Batt ... r-Parallel

As a side note for what I know you should not connect batteries of different voltages in parallel, as it would result in damage. That is because they are not ideal and they are a chemical device.

But for sound I guess the thing is the frequency of oscillation, not the voltage amplitude, and most probably the output waveform is the sum of the three waveforms.

Just guessing...

P.S. Still nothing explains why I have a horrible noise when playing the digitized sound in Quintessential but not the music in Oric-Tech (which is also made of samples?).
User avatar
Dbug
Site Admin
Posts: 4437
Joined: Fri Jan 06, 2006 10:00 pm
Location: Oslo, Norway
Contact:

Re: Oric's 8912 volume scale

Post by Dbug »

Chema wrote:P.S. Still nothing explains why I have a horrible noise when playing the digitized sound in Quintessential but not the music in Oric-Tech (which is also made of samples?).
We are using different routines for the different demos:
- The "Welcome" in "Just Oric" is a 8bit sample replayed using three channels and Atari ST Replay log conversion tables
- The "DTS" and "20st Century Fox" in Quintessential are 4 bit samples replayed one one channel, with values very naively converted from the 8bit source. It sounds like hell on my machine as well :D
- The final sample over the flickering scroll text in Quintessential is Twilighte's routine that uses the VIA shift register, it works on some machines (my Pravetz) not on some other (my Atmos)
- The sample in Oric Tech is a variant of the DTS/20st Century, using a better 4bit conversion, but it's essentially the same code (that being said, may be the VIA selection code was tweaked, can't remember)

To summarize, what can impact the replay is:
- Using the shift register on the VIA
- Having a sound-chip with linear volume tables instead of logarithmic
Godzil
Squad Leader
Posts: 774
Joined: Sat May 21, 2011 7:21 pm
Location: Between UK and France
Contact:

Re: Oric's 8912 volume scale

Post by Godzil »

meynaf wrote:
Godzil wrote: No it's not the same, channel A is outputing a 440Hz square wave for exemple, and B & C are forced at 1V, you will have a 1V (full scale) square wave. If B and C are forced at 0V (which is more likely IRL) it will oscillate between 0 and 0.3333V

It's the same things as connecting AA battery in parallel, the voltage is not adding, you are not going to have 4.5V by doind that, but only 1.5V (or less if they don't have the same voltage)
From the formula you gave it is the same. It's just that instead of merely adding, an average is made. However it's like dividing by 3 and then adding. It's still a sum at the end.
So your three 1.5V AA batteries can be looked like three 0.5V ones, with added voltage. If not, i'm more and more confused :?
I'm sorry it's hard to explain without going into basic electronics, but if you freeze the system, take measure of output voltage of each channel independently, then want to calculated the output voltage when the three are mixed the way they are mixed on the Oric, you just do

(VoltageCHA + VoltageCHB + VoltageCHC) / 3 = TotalVoltage

If you want to know more, I recommend to read about Kirchhoff laws: https://en.wikipedia.org/wiki/Kirchhoff ... rcuit_laws

Just another crude example:
Capture d’écran 2016-07-20 à 11.55.06.png
(forget the part that goes to the right, it's not connected and don't have any impact on the circuit

The scope output looks like this:
Capture d’écran 2016-07-20 à 11.55.14.png
Capture d’écran 2016-07-20 à 11.55.14.png (17.59 KiB) Viewed 22050 times
As you can see there is 4 different voltages, one at 0V, one a 0.3333333..V one at 0.6666666....V and the last a about 1V each of them depending on how many channels are at 1, and if you look at the schematics, two channels are currently outputing 1V, the end voltage is about 0.66666...V


What Chema says is true about battery, if you put batteries of different voltages, the same as what I say apply, but the issue is, instead of all the battery outputting current the lower voltages one are going to receive current from the higher voltages one. That's an issue for batteries are they are not made for that, it's not a real issue for our GI/YM chip as all the channel can't output a lot of current, and it's made to work like this.

To try to make things simple, when current goes to a node with multiples paths to exit and each path have the same resistance, it will split evenly in each paths, and that's what happening there.
User avatar
meynaf
1st Star Corporal
Posts: 14
Joined: Mon Jul 18, 2016 6:37 pm
Location: Lyon (France)
Contact:

Re: Oric's 8912 volume scale

Post by meynaf »

Godzil wrote: (VoltageCHA + VoltageCHB + VoltageCHC) / 3 = TotalVoltage
That's what i'm saying, it is a sum.
Because it's the same thing as :
VoltageCHA/3 + VoltageCHB/3 + VoltageCHC/3 = TotalVoltage


But applying this formula in YM/GI emulation code is doomed to fail.
There are other things at play.

For the YM i roughly know (at least i have the volume tables used in Steem).

But for the AY in the oric, i have no clue.
The amp and the loudspeaker seem to be limiting the amplitude.
By ear i'd say maximum amplitude is around volume 13. But who knows.
This is the whole purpose of my question here.
User avatar
iss
Wing Commander
Posts: 1637
Joined: Sat Apr 03, 2010 5:43 pm
Location: Bulgaria
Contact:

Re: Oric's 8912 volume scale

Post by iss »

Very interesting discussion!
@meynaf: Where did you found the value 1V max output? In AY-3-8912.pdf is written "NORMALIZED voltage range" which is obvious different from the absolute 0..1V range.
Else, +1 for everything that Godzil explained, but because "seeing is believing" ...
here are real values measured on pins 1,4,5 of AY-3-8912 (they are connected directly together in Oric):
- Channel A = max 0.917V
- Channel A+B = max 1.30V
- Channel A+B+C = max 1.58V
Values are produced using this Basic code:

Code: Select all

10 MUSIC 1,3,6,15
20 MUSIC 2,3,6,15 <- comment to disable chan.B
30 MUSIC 3,3,6,15 <- comment to disable chan.C
40 PLAY 7,0,15,0
1,2,3 channels and speaker voltage output
1,2,3 channels and speaker voltage output
Oric amplifier schematic
Oric amplifier schematic
Mathematical proof: ;)
Let's take the value of 3 channels (right two pictures above),
on pin 1,4,5 is 1.58V from schematic R2 and R3 are voltage divider 1:11 i.e.
the input value range for the LM386 is 1.58V / 11 = 0,1436V,
according to LM386.pdf (see Typical Applications first picture) the LM386 is Amplifier with Gain = 20 (Minimum Parts), then the voltage range on the speaker will be: 0,1436V * 20 = 2,872V or 2.88V as on the last oscillogram. :)
At end to be more practical: if there is saturation in output - try to replace at least C1 and C4 and check the values of R2 and R3. Good luck!
User avatar
meynaf
1st Star Corporal
Posts: 14
Joined: Mon Jul 18, 2016 6:37 pm
Location: Lyon (France)
Contact:

Re: Oric's 8912 volume scale

Post by meynaf »

iss wrote: @meynaf: Where did you found the value 1V max output? In AY-3-8912.pdf is written "NORMALIZED voltage range" which is obvious different from the absolute 0..1V range.
As said, i'm quite noob in electronics. I read "1V" in the manual, so for me a single channel outputted max 1V.
I'm just a programmer trying to correctly emulate the original oric's sound.
The exact output voltage is of no importance ; what's important is the volume level i must use in my software to get the same result.

iss wrote: Else, +1 for everything that Godzil explained, but because "seeing is believing" ...
here are real values measured on pins 1,4,5 of AY-3-8912 (they are connected directly together in Oric):
- Channel A = max 0.917V
- Channel A+B = max 1.30V
- Channel A+B+C = max 1.58V
Values are produced using this Basic code:

Code: Select all

10 MUSIC 1,3,6,15
20 MUSIC 2,3,6,15 <- comment to disable chan.B
30 MUSIC 3,3,6,15 <- comment to disable chan.C
40 PLAY 7,0,15,0
osc.jpg
Oric-amp.jpg
Mathematical proof: ;)
Let's take the value of 3 channels (right two pictures above),
on pin 1,4,5 is 1.58V from schematic R2 and R3 are voltage divider 1:11 i.e.
the input value range for the LM386 is 1.58V / 11 = 0,1436V,
according to LM386.pdf (see Typical Applications first picture) the LM386 is Amplifier with Gain = 20 (Minimum Parts), then the voltage range on the speaker will be: 0,1436V * 20 = 2,872V or 2.88V as on the last oscillogram. :)
At end to be more practical: if there is saturation in output - try to replace at least C1 and C4 and check the values of R2 and R3. Good luck!
This gets more and more confusing.

Let's say i have two channels running at max volume.
Any channel will give 0.917V alone according to your measurements.
So i setup a single PCM channel with (in my units) amplitude 64.
If i just setup another PCM channel with the same amplitude, i'll get total 128.
According to your measurements i should get something like 90.73.

This means i have to reduce the PCM amplitude of individual channels when several are running !
For me it sounds just plain crazy - the perceived volume level is reduced for a sound when other sounds are played on top of it...
User avatar
iss
Wing Commander
Posts: 1637
Joined: Sat Apr 03, 2010 5:43 pm
Location: Bulgaria
Contact:

Re: Oric's 8912 volume scale

Post by iss »

If the case is for emulation only, you can take a look in Oricutron and Euphoric sources.
Additionally kind of info about math interpolation (in Czech language) can be found here and here.
I hope this (somehow) will help.
User avatar
meynaf
1st Star Corporal
Posts: 14
Joined: Mon Jul 18, 2016 6:37 pm
Location: Lyon (France)
Contact:

Re: Oric's 8912 volume scale

Post by meynaf »

iss wrote:If the case is for emulation only, you can take a look in Oricutron and Euphoric sources.
This kind of emulation takes a lot more cpu than what i intend to use. I prefer something simpler ; does not need to be perfect but must be realistic enough.
I'm not writing an oric emulator, just some simple music player for my old oric musics.
Godzil
Squad Leader
Posts: 774
Joined: Sat May 21, 2011 7:21 pm
Location: Between UK and France
Contact:

Re: Oric's 8912 volume scale

Post by Godzil »

meynaf wrote:
iss wrote:If the case is for emulation only, you can take a look in Oricutron and Euphoric sources.
This kind of emulation takes a lot more cpu than what i intend to use. I prefer something simpler ; does not need to be perfect but must be realistic enough.
I'm not writing an oric emulator, just some simple music player for my old oric musics.

If you are looking for emulating an GI/AY chip, you can look at that code: http://obex.parallax.com/object/153

It's not made for a classic CPU, but the assembly code is quite easy to read and really straight forward.
User avatar
meynaf
1st Star Corporal
Posts: 14
Joined: Mon Jul 18, 2016 6:37 pm
Location: Lyon (France)
Contact:

Re: Oric's 8912 volume scale

Post by meynaf »

Godzil wrote: If you are looking for emulating an GI/AY chip, you can look at that code: http://obex.parallax.com/object/153

It's not made for a classic CPU, but the assembly code is quite easy to read and really straight forward.
I already have this kind of emulation stuff. What i want is oric specific differences.
Godzil
Squad Leader
Posts: 774
Joined: Sat May 21, 2011 7:21 pm
Location: Between UK and France
Contact:

Re: Oric's 8912 volume scale

Post by Godzil »

meynaf wrote:
Godzil wrote: If you are looking for emulating an GI/AY chip, you can look at that code: http://obex.parallax.com/object/153

It's not made for a classic CPU, but the assembly code is quite easy to read and really straight forward.
I already have this kind of emulation stuff. What i want is oric specific differences.

Sorry I don't get it, there is nothing specific to the Oric. The GI is a standard one, and the way it is connected is pretty standard too. The amplifier have nothing special and the filter after the GI/YM is just to remove some high & low frequencies that you can't hear. And if there is any distortion it's not the "Oric Sound" it's just the quality of the passive components on your board, if the resistors of the capacitors had failed in some way, the filter may not work as expected, same for the LM386. But technically there is no differences between an Oric and an Atari ST, the channel mixing is done in the same way.
User avatar
Dbug
Site Admin
Posts: 4437
Joined: Fri Jan 06, 2006 10:00 pm
Location: Oslo, Norway
Contact:

Re: Oric's 8912 volume scale

Post by Dbug »

Then I guess it's probably possible to add a filter on the output to simulate the distorted audio :)

"sound of old electronics"
User avatar
meynaf
1st Star Corporal
Posts: 14
Joined: Mon Jul 18, 2016 6:37 pm
Location: Lyon (France)
Contact:

Re: Oric's 8912 volume scale

Post by meynaf »

Godzil wrote: But technically there is no differences between an Oric and an Atari ST, the channel mixing is done in the same way.
Really, no.
They're identical only on the paper. I heard the differences.
If you look at a good YM emulator you will see that it doesn't do linear mixing. Rather, it uses levels measured from actual output (i have these). And if you have a look at such a volume table, you will see it doesn't behave like the theory expects.

The electronics doing the mixing and filtering, isn't the same either.

You still don't believe me ? Measure the output levels !
Someone here did this for the Oric. Perhaps comparing with the ST could open some eyes.
First, the formula you gave was : (V1 + V2 + V3) / 3.
But the actual measured levels on an Oric (as given earlier in this thread : 0.917, 1.30, 1.58) rather suggest it is : SQR (V1² + V2² + V3²).
Now from the Atari ST you will again get different values.
If we set the "single channel" value to be the same (even if we can be pretty sure it won't), the results would be 0.917, 1.419, 1.649, i.e. not what you expect them to be.

Perceived volume levels should follow the measurements on the Atari ST as it's usually plugged in some monitor's audio which ought to be good enough unless you push the volume too much, but the Oric uses its small loudspeaker which can easily saturate at high volume levels. Perhaps an heavily modded Oric will sound more like the ST. But it's not identical and it's not the kind of sound i want ; i already have this.

Dbug wrote:Then I guess it's probably possible to add a filter on the output to simulate the distorted audio :)

"sound of old electronics"
Yes this is kinda what i want to do. Perhaps this is simple clipping of high volume levels, i don't know.
User avatar
Dbug
Site Admin
Posts: 4437
Joined: Fri Jan 06, 2006 10:00 pm
Location: Oslo, Norway
Contact:

Re: Oric's 8912 volume scale

Post by Dbug »

On the topic, there's some interesting details about sound on Gunstick's presentation: https://www.youtube.com/watch?v=yLDtiTS4JLg
Around the 34th minute there are some Audacity sample output of the three channels, and discussion of the shape on emulators vs real machine.
Post Reply