Beeper octave range...
A dumb question, I know, but I've found two conflicting sources of information on the octave range of the Sinclair beeper.
I suppose I'm being a little bit lazy, but does anyone know off-hand the octave range of the Speccy beeper.
Andrew
I suppose I'm being a little bit lazy, but does anyone know off-hand the octave range of the Speccy beeper.
Andrew
Post edited by andrew_rollings on
Comments
Divide by 12 surely. Go as high as you can go, divide by 12, go as low as you can go, divide by 12 and then add the two answers.
But this is the spectrum beep command, not the octave range of the beeper. That octave range will be below what squirrels can hear and above what dogs can hear. The driving circuit of the beeper does effectively place a low pass filter with 3db frequency of 11kHz which attenuates frequencies above that and will be dc-coupled which will attenuate low frequencies. I'm sure the mechanical characteristics of the speaker itself has a 3db frequency higher than 11kHz.
Since the speaker is driven by a 3.5MHz cpu there is much greater output range than '80s sound-generating ics which depended on finite size registers and a fixed clock to generate tone periods, both of which were usually more limited in comparison to what could be mustered by the cpu.
The highest frequency tone that can be generated by the z80 is probably this:
which is 40 cycles and at 3.5MHz corresponds to a tone at 87.5kHz. The lowest frequency that could be generated is effectively 0Hz but let's say 10Hz for purposes of calculating an octave range. Then the octave range would be log(87.5kHz/10Hz)/log 2 = 13 octaves. However the density of high frequency tones that can be generated below 87.5kHz is not too good. If you use the 3db frequency of the driving circuit at 11kHz, which will give good tone generation resolution, but will underestimate the octave range, then you get log(11kHz/10Hz)/log 2 = 10 octaves.
Write games in C using Z88DK and SP1
And I'll have to ask my wife what an octave is ;)
Nice code, what about this:
34 cycles
The problem is, although this might be the highest frequency that you can get the CPU to whack the speaker, these is no musical granularity or quality to this pitch e.g. you couldn't make it play 1,2 or 3 or even 12 "semitones lower" than this frequency.
Risking another comment:
OUT (C),A appears to be slower than OUT (254),A
12 Cycles against 11!
(source www.z80.info)
A4 is 440 Hz, each octave doubles (or halves, respectively) this, and you have 12 semitones per octave, so it means each semitone multiplies (or divides, respectively) this frequency by twelfth root of two if you want equal temperament. The 48k CPU frequency is 3.5MHz, so it is easy to do the math how many T cycles you need for each semitone. You'll probably want to convert it directly to the timing constants for your OUTing loop, though.
Of course, these constants give you the values for the entire period. If you want to have some fun with volume, you may change the duty of the wave. This is basically done by adjusting the duration of each half-period, while keeping the total period constant. Keeping the half-periods the same gives you middle duty wave, while extending or shortening the duration of the high level gives you heavier or lower duty wave, respectively. This will work only to some extent though. If you would want to have real volume control, you would need to go for proper synthesis, mixing and 1bit DAC simulation.
Edit: No it doesn't double it. That was me being a bit thick there :p
OT: if im correct you wrote Star Dragon's beeper driver. what it is its tech specs ? (just curious, i like the tune)
Eight octaves.
Probably wrong, but the thread has got way out of hand, so I thought I'd remind you that there are some "normal" people here who can give you straight answers - right or wrong :D:D:D
org 32768 di ld sp,49151 ld a,3 call FillRam ld a,6 call FillRam ld a,7 call FillRam ld a,4 call FillRam ld bc,#7FFD ld a,8 out (c),a ld bc,#07FE ld a,#1F out (#FD),a FillRam: ld bc,#7ffd or 16 out (c),a pop ix ld sp,0 ld hl,#41ED ld de,#FED3 ld bc,16 FillLoop: push hl push de djnz FillLoop dec c jr nz,FillLoop jp (ix)I've been very amused by the sudden outbreak of spoddiness :)
Seriously though, these are all interesting answers, as the two conflicting figures I'd found previously were 5 and 10 octaves...
This thread will make an interesting footnote in the chapter :D
Andrew
You just know the optimisation freaks (you included) are now gunna jump (push hl and return) in...
"Load 'A' with 8"?
Are you mad? LOAD the accumulator? You LOAD the ACCUMULATOR?
With 8?
...you are MAD!
Insane.
For posterity the correct answerTM is 10 octaves. Not sure why anyone would get five except that maybe they ran the BEEP program out of the manual but in one direction only (only +ve semitone values, eg).
Burn the witch!
Write games in C using Z88DK and SP1
Ok, being not assembly optimisation minded, what's wrong with that exactly? Anyone care to shed some light on this?
Bytes:Chuntey - Spectrum tech blog.
ld bc,#7FFD ld a,8 out (c),aBut personally I just think fffimS nahtanoJ is a bit of a nutter! :)
Dons flame-proof jacket.
And gonad shield :p
Not exactly, the player originally comes from Savage, and I don't even remember if I had changed anything at all. It is two channels and drums, and I would have to look up how many octaves it supports, at least six would be my guess, eight being more likely.
Back to the documentation thing, maybe someone could make a BEEPer wiki? Even if it's just all the info from the various WoS threads on the subject, it would still be a useful reference point. Besides the PC, do any other computers have a beeper?