Page 1 of 1
BEEP
Posted: Sat Dec 24, 2022 6:57 pm
by Andrew
Is there a simple way to convert ZX Spectrum BEEP to QL BEEP?
length is easy to calculate (ZX Spectrum is in seconds, QL's in 72 microseconds increments) but how to convert pitch?
Re: BEEP
Posted: Sat Dec 24, 2022 10:23 pm
by Mark Swift
An interesting problem.
I haven't got a way of testing if the below is right, but here goes...
On the QL:
BEEP <pitch>,<duration>
Gives a frequency approximately equal to 11447/(10.6+<pitch>) Hz and a duration of <duration>*72/1000000 seconds
So: QL_pitch=(11447/freq)-10.6
A quick google shows that on the Spectrum, pitch is given in semitones above middle C (261.63Hz) using negative numbers for notes below middle C.
So Spectrum_pitch 0 = QL_pitch (11447/261.63)-10.6 = 33.15
With each spectrum pitch increment, you multiply the frequency produced by EXP(LN(2)/12)
This means that
QL_pitch = (11447/( 261.63*EXP(LN(2)/12)^Spectrum_pitch ))-10.6
I assume you would have to round the result up or down
Re: BEEP
Posted: Sun Dec 25, 2022 10:17 am
by Andrew
Thank you Mark!
I will write a short program to convert a Spectrum Beep melody to Ql and see how it sounds!
Re: BEEP
Posted: Sun Dec 25, 2022 4:27 pm
by janbredenbeek
No easy way, the QL's pitch range is rather limited compared to the Spectrum's.
I've once written a BCSOUND procedure for implementing sound in BASICODE, which uses parameters similar to the Spectrum's, though the pitch is offset by 60 (which is middle-C). The QL's hardware limits the pitch range from 29 to 88 (-31 to 28 in Spectrum pitch) and because of the granularity in pitch steps the sound produced may be slightly out of tune.
Source code is
here, it starts at line 999. If you want to try it, LRESPR BCRAM_BIN from the main page.
Re: BEEP
Posted: Tue Dec 27, 2022 12:29 pm
by Exile
Hi,
When adding the sound code for sQLux I realised that, despite what it says in the manual, the length of sound for a QL is
not in units of 72 microseconds, for "simple" Beeps it is about 43.64 microseconds, although the time base can get longer if several of the optional Beep parameters are used. This time is related to 8049 clock rate (22917). I did confirm this by recording and timing Beeps from a BBQL.
https://github.com/SinclairQL/sQLux/blo ... d#56-sound