BEEP VAL
- alban lusitanae
- Berk
- Posts: 11
- Joined: Fri Jun 28, 2019 12:49 pm
- Location: Portugal
- Contact:
BEEP VAL
Hi to all
Been seeing in some test programs the usage of BEEP VAL "xyz" in more or less the same way the Poke Usr Data is normally used,
you do BEEP VAL and then between brackets insert a continuous string.
I have not found any good sources around this (guess it was another thing only know if you took a course at the time or bought some specialty magazines)?
Best regards
Been seeing in some test programs the usage of BEEP VAL "xyz" in more or less the same way the Poke Usr Data is normally used,
you do BEEP VAL and then between brackets insert a continuous string.
I have not found any good sources around this (guess it was another thing only know if you took a course at the time or bought some specialty magazines)?
Best regards
1 x
- 1024MAK
- Manic Miner
- Posts: 535
- Joined: Wed Nov 15, 2017 2:52 pm
- Location: Sunny Somerset in the U.K. in Europe
Re: BEEP VAL
BEEP needs two parameters, the tone value and the duration.
VAL is a function that evaluates a string and returns (when possible) a number. VAL can be used to reduce the memory usage of a program. This may confuse you. ZX Spectrum BASIC hides a floating point version of any numerical constant (number) in a program. A numerical constant in the program is followed by its binary form, using the character 'CHR$ 14' followed by five bytes for the number itself. So the number 2 actually takes up 7 bytes!
However, I think you may be thinking of:
SOUND “abc”
SOUND requires a string expression, the letters in the string are the musical notes.
SOUND is only available on the 128K machines which have a dedicated sound chip (AY).
BEEP uses the ULA / gate array and is available on all ZX Spectrum models.
For more information read this section of the manual.
Mark
VAL is a function that evaluates a string and returns (when possible) a number. VAL can be used to reduce the memory usage of a program. This may confuse you. ZX Spectrum BASIC hides a floating point version of any numerical constant (number) in a program. A numerical constant in the program is followed by its binary form, using the character 'CHR$ 14' followed by five bytes for the number itself. So the number 2 actually takes up 7 bytes!
However, I think you may be thinking of:
SOUND “abc”
SOUND requires a string expression, the letters in the string are the musical notes.
SOUND is only available on the 128K machines which have a dedicated sound chip (AY).
BEEP uses the ULA / gate array and is available on all ZX Spectrum models.
For more information read this section of the manual.
Mark
1 x
Re: BEEP VAL
It's PLAY not SOUND, but otherwise 1024MAK has hit the nail on the head. It's usually about saving space.
0 x
- alban lusitanae
- Berk
- Posts: 11
- Joined: Fri Jun 28, 2019 12:49 pm
- Location: Portugal
- Contact:
Re: BEEP VAL
Oh i kmow PLAY and I know i cannot use it except in 128k. Saving space is great because i tend to just keep creating things and run out of memory. I just need to know how i can string the two variables of beep in it. I ll check it out and revert if i cant figure out the code. Many thx.
0 x
- 1024MAK
- Manic Miner
- Posts: 535
- Joined: Wed Nov 15, 2017 2:52 pm
- Location: Sunny Somerset in the U.K. in Europe
Re: BEEP VAL
NOTE: above quotation edited to change SOUND (which is wrong!) to PLAY (which is correct).1024MAK wrote: ↑Mon Jul 15, 2019 5:29 pmBEEP needs two parameters, the tone value and the duration.
VAL is a function that evaluates a string and returns (when possible) a number. VAL can be used to reduce the memory usage of a program. This may confuse you. ZX Spectrum BASIC hides a floating point version of any numerical constant (number) in a program. A numerical constant in the program is followed by its binary form, using the character 'CHR$ 14' followed by five bytes for the number itself. So the number 2 actually takes up 7 bytes!
However, I think you may be thinking of:
PLAY “abc”
PLAY requires a string expression, the letters in the string are the musical notes.
PLAY is only available on the 128K machines which have a dedicated sound chip (AY).
BEEP uses the ULA / gate array and is available on all ZX Spectrum models.
For more information read this section of the manual.
Mark
Yes, working nights must have screwed with my head!

It is PLAY not SOUND. I must have been thinking about another computers BASIC at the time

Can you tell that I am tone deaf

Mark
PS If a friendly moderator or administrator feels like sorting out my mess, please feel free to do so...

0 x
- 1024MAK
- Manic Miner
- Posts: 535
- Joined: Wed Nov 15, 2017 2:52 pm
- Location: Sunny Somerset in the U.K. in Europe
Re: BEEP VAL
Try:alban lusitanae wrote: ↑Tue Jul 16, 2019 5:59 amOh i kmow PLAY and I know i cannot use it except in 128k. Saving space is great because i tend to just keep creating things and run out of memory. I just need to know how i can string the two variables of beep in it. I ll check it out and revert if i cant figure out the code. Many thx.
BEEP VAL “.2”,VAL “1”
Or
BEEP VAL “.2”,PI
Where PI is the function on the M key...
Mark
0 x
- Einar Saukas
- Manic Miner
- Posts: 949
- Joined: Wed Nov 15, 2017 2:48 pm
Re: BEEP VAL
The BEEP command is called SOUND in the Sinclair BASIC of Brazilian clone TK90X.
And the PLAY command is called SOUND in the Sinclair BASIC of Timex models.
1 x
Re: BEEP VAL
I wondered, why, if the Z80 has to produce the sound anyway and execution of BASIC had to been stopped for that purpose, the didn't they use pwm. Maybe this would not have worked to well for higher frequencies, but still.
Last edited by 1bvl109 on Tue Jul 16, 2019 6:04 pm, edited 1 time in total.
0 x
"Truth would quickly cease to be stranger than fiction, once we got used to it." - H.L. Mencken
Re: BEEP VAL
In his (highly recommended) ULA reverse-engineering book, Chris Smith documents that the sound generation shares the same circuit as the tape output, and surmises it was done that way for efficiency (needing less logic gates in the ULA, which means more room to fit other functionality in).
1 x
Re: BEEP VAL
SOUNDS reasonable.
But wouldn't it have been possible, to send, say 4 or 5 bits out through a https://en.wikipedia.org/wiki/Resistor_ladder ?
0 x
"Truth would quickly cease to be stranger than fiction, once we got used to it." - H.L. Mencken