YM2149 Tutorial Questions

Started by Baggey, October 13, 2023, 06:40:42

Previous topic - Next topic

Baggey

Hi @Midimaster,

In your tutorial you explain a 100hz Tone having 480 Steps. Is that 1 Complete Wave?

Am, i right in saying at 48000 samples if i sent 109 square waves id get. 440.36Hz tone which would be a Square Wave "A above middle C"

Baggey
Running a PC that just Aint fast enough!? i7 4Ghz Quad core 24GB ram 1TB SSD and NVIDIA Quadro K620 . DID Technology stop! Or have we been assimulated!

ZX Spectrum 48k, C64, ORIC Atmos 48K, Enterprise 128K, The SID chip. Im Misunderstood!

Baggey

In the TGenerator Tutorial you use the OneStep() Function. So indeed we are making a wave for every Sample.

If im following, we have created 480 samples using the OneStep() Function. Giving "1 to 0 to -1" which gives 2 changes for every sample sent :-\ Making the Square wave and sending that into Generator 1, which is our "Square Wave Generator" as 480 Samples.

So we have made a Square Waved Tone of the Note "G2"

Baggey
Running a PC that just Aint fast enough!? i7 4Ghz Quad core 24GB ram 1TB SSD and NVIDIA Quadro K620 . DID Technology stop! Or have we been assimulated!

ZX Spectrum 48k, C64, ORIC Atmos 48K, Enterprise 128K, The SID chip. Im Misunderstood!

Midimaster

Quote from: Baggey on October 13, 2023, 06:40:42...In your tutorial you explain a 100hz Tone having 480 Steps. Is that 1 Complete Wave?

Am, i right in saying at 48000 samples if i sent 109 square waves id get. 440.36Hz tone which would be a Square Wave "A above middle C" ...
Yes a 100Hz tone needs 480 steps in a 48kHz Device to fullfill a complete wave (positiv and negativ part)

Yes 109 steps would result in a (nearly) 440Hz tone A.

With this questiion you already pointed to a problem what we will get with INTEGER, when we want to reach an exact HERTZ frequency like 440Hz. With a period length of 109 we can only reach 440,36 Hz. And the deviation rises, when we try to build higher frequencies. In the today's lesson "Convert YM-periods to 48kHz-periods" I will take care about this and change the counter to a DOUBLE type.



QuoteIn the TGenerator Tutorial you use the OneStep() Function. So indeed we are making a wave for every Sample.

If im following, we have created 480 samples using the OneStep() Function. Giving "1 to 0 to -1" which gives 2 changes for every sample sent :-\ Making the Square wave and sending that into Generator 1, which is our "Square Wave Generator" as 480 Samples.

So we have made a Square Waved Tone of the Note "G2"

OneStep() does not build a whole wave, but only one wave-point on the shape of the wave. Related on the Counter it "calculates" the single value that we will add to the CallBack()-Buffer. As we jump into the  OneStep() 480 times during one CallBack-loop we create a whole wave of 100Hz, but we would create 2 complete waves of 200Hz, if the Period would be 240 instead of 480.

But it is not the note G2, because G2 is 98Hz and G#2 is 103Hz. We are in the middle between both tones and this would not be acceptable for music. 1% is the maximum deviation audience would accept, 2.5% are already a "quarter tone step"--->worst case. And 5% deviation is already the next tone. So to build G2 we would use 490Hz with a deviation below 0.2%

You cannot say "we send into the generator", because the generator is the sender! We instruct the generator to flip the state when we are telling him the Period length. With this instruction the generator is able to build the wave independent.
...back from Egypt

Baggey

Quoteto find out what is right or wrong, we would need a vintage machine to compare the sounds at the speakers.
One computer i dont have is an Atarti ST 520.

Some Die hards would say its not exact. For me i would go with what sounds best to the ears :)

The Bassier approach is better i think also. This can be seen as being Improved upon / made better.

Baggey
Running a PC that just Aint fast enough!? i7 4Ghz Quad core 24GB ram 1TB SSD and NVIDIA Quadro K620 . DID Technology stop! Or have we been assimulated!

ZX Spectrum 48k, C64, ORIC Atmos 48K, Enterprise 128K, The SID chip. Im Misunderstood!

Baggey


QuoteAs a developer you can play around with both ideas. I keep all optimizations and basic approaches in the Class. 
Could you explain what you mean by Class!? :-\

In English a class is where children sit in front of a teacher? or is this an Americanisation of english?

Kind Regards Baggey
Running a PC that just Aint fast enough!? i7 4Ghz Quad core 24GB ram 1TB SSD and NVIDIA Quadro K620 . DID Technology stop! Or have we been assimulated!

ZX Spectrum 48k, C64, ORIC Atmos 48K, Enterprise 128K, The SID chip. Im Misunderstood!

Midimaster

The expression CLASS comes from the language C. CLASSes do not really exist in BlitzMax. But we can simulate them with TYPEs.

A Class is a encapsulated collection of functions that use a complete independent Name-Room. Means that all "inside used variables" are already defined inside the class. When somebody adds a CLASS to his main code, he need not to care about collisions of variable names, because the CLASS guarantees that their are no collisions.

A lot of the functions and methods of a CLASS are not open to public. PRIVATE means "do not use from outside". Normally also all variables inside a CLASS are private.

To interface with the main code a class hasso called PUBLIC functions or SET/GET-functions to reach inside variables.

Example I:
In cooperation with our YM-TYPE we need not define the Const SQUARE in our main code, because it is already defined inside the TYPE. If you need this Const also outside (in your main code) you can define it twice (without getting any problems) or you could use YM.SQUARE

Example II:

We do not set the Registers with direct code:YM.Register[1]=123 ( ...although it would be technically possible)

 but we use a "SET"-function:
YM.SetRegister 1, 123

Type YM
Function SetRegister(Adress:Int, Value:Int)
Register[Adress]=Value and 255
End Function
...
This guarantees that nobody can fill variables with invalid values

This all guarantees that many people can use the Class without the need to change something in their main code.


...back from Egypt

Baggey

Awsome Tutorial, I keep find myself waiting for the next  :o

Ive recently just got my head around Tlist and Types with Arrays. I see you've used them in the GUI Concept with the use of .self.

Something else to learn. I sort of get it but don't fully understand :-\ When i get some more time i shall play with this idea.

Didn't realize that noise is mixed in with the normal channels. I think You can also Play just AB and BC or CA out of Left and Right speakers as well ::)
The ZX Spectrum only used Mono though. However there are addons which give Stereo. So it was capable but only had a mono socket? Probably because of the single onboard speaker.

              -- CBA CBA
Register 7 = "00|101|001"

Getting rusty, but i believe this is more todo with how the chips are wired on the motherboard. When a voltage is applied to the chip it can be seen but when not it floats. So they used Pull up and Pull down resistors to get precise Logic levels/Voltage rather than it Float. This could cause unwanted on/off or Some sort off noise. So, The YM would see definate On/Off albeit active Low. And know when to act on the control bits.

This if not emulated or masked could cause unwanted pips/noise in emulation. If the bits aren't masked or are left floating i believe. From residual bits on the Bus/Registers previous use. :-\

Thankyou for your time on this tutorial. Sound being created in the Digital form is something im very interested in understanding. ;D

Kind Regards Baggey
Running a PC that just Aint fast enough!? i7 4Ghz Quad core 24GB ram 1TB SSD and NVIDIA Quadro K620 . DID Technology stop! Or have we been assimulated!

ZX Spectrum 48k, C64, ORIC Atmos 48K, Enterprise 128K, The SID chip. Im Misunderstood!

Baggey

Take on me by A-Ha FRIKEN AWSOME.

Nice Bassy Tone's Better than the real thing! 8)

Cant wait to play with the code.

Kind Regards Lee
Running a PC that just Aint fast enough!? i7 4Ghz Quad core 24GB ram 1TB SSD and NVIDIA Quadro K620 . DID Technology stop! Or have we been assimulated!

ZX Spectrum 48k, C64, ORIC Atmos 48K, Enterprise 128K, The SID chip. Im Misunderstood!