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?
BEEP
- Mark Swift
- Bent Pin Expansion Port
- Posts: 86
- Joined: Fri Jul 18, 2014 9:13 am
- Location: Blackpool, Lancs, UK
- Contact:
Re: BEEP
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
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
- janbredenbeek
- Super Gold Card
- Posts: 668
- Joined: Wed Jan 21, 2015 4:54 pm
- Location: Hilversum, The Netherlands
- Contact:
Re: BEEP
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.
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
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
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