BEEP VAL

The place for codemasters or beginners to talk about programming any language for the Spectrum.
User avatar
alban lusitanae
Berk
Posts: 11
Joined: Fri Jun 28, 2019 12:49 pm
Location: Portugal
Contact:

BEEP VAL

Post by alban lusitanae » Mon Jul 15, 2019 4:22 pm

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
1 x

User avatar
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

Post by 1024MAK » Mon Jul 15, 2019 5:29 pm

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
1 x

AndyC
Manic Miner
Posts: 251
Joined: Mon Nov 13, 2017 5:12 am

Re: BEEP VAL

Post by AndyC » Mon Jul 15, 2019 7:50 pm

It's PLAY not SOUND, but otherwise 1024MAK has hit the nail on the head. It's usually about saving space.
0 x

User avatar
alban lusitanae
Berk
Posts: 11
Joined: Fri Jun 28, 2019 12:49 pm
Location: Portugal
Contact:

Re: BEEP VAL

Post by alban lusitanae » Tue Jul 16, 2019 5:59 am

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

User avatar
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

Post by 1024MAK » Tue Jul 16, 2019 7:44 am

1024MAK wrote:
Mon Jul 15, 2019 5:29 pm
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:
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
NOTE: above quotation edited to change SOUND (which is wrong!) to PLAY (which is correct).

Yes, working nights must have screwed with my head! :lol:
It is PLAY not SOUND. I must have been thinking about another computers BASIC at the time :oops:

Can you tell that I am tone deaf :lol:

Mark

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

User avatar
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

Post by 1024MAK » Tue Jul 16, 2019 7:56 am

alban lusitanae wrote:
Tue Jul 16, 2019 5:59 am
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.
Try:
BEEP VAL “.2”,VAL “1”

Or

BEEP VAL “.2”,PI

Where PI is the function on the M key...

Mark
0 x

User avatar
Einar Saukas
Manic Miner
Posts: 949
Joined: Wed Nov 15, 2017 2:48 pm

Re: BEEP VAL

Post by Einar Saukas » Tue Jul 16, 2019 2:40 pm

1024MAK wrote:
Tue Jul 16, 2019 7:44 am
It is PLAY not SOUND. I must have been thinking about another computers BASIC at the time :oops:
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

User avatar
1bvl109
Dizzy
Posts: 52
Joined: Tue Jun 04, 2019 8:00 pm

Re: BEEP VAL

Post by 1bvl109 » Tue Jul 16, 2019 4:39 pm

1024MAK wrote:
Mon Jul 15, 2019 5:29 pm
BEEP uses the ULA / gate array and is available on all ZX Spectrum models.
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

User avatar
Seven.FFF
Manic Miner
Posts: 341
Joined: Sat Nov 25, 2017 10:50 pm
Location: USA

Re: BEEP VAL

Post by Seven.FFF » Tue Jul 16, 2019 4:47 pm

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
Robin Verhagen-Guest
SevenFFF / Threetwosevensixseven / colonel32
seven-fff.com/blog

User avatar
1bvl109
Dizzy
Posts: 52
Joined: Tue Jun 04, 2019 8:00 pm

Re: BEEP VAL

Post by 1bvl109 » Tue Jul 16, 2019 7:16 pm

Seven.FFF wrote:
Tue Jul 16, 2019 4:47 pm
... 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).
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

Post Reply