The pitch of the sound is strange. (NextBASIC "PLAY" statement)

This section is for discussing everything about Next hardware and latest updates.
Post Reply
PiyoTaro
Posts: 176
Joined: Thu Jun 01, 2017 11:13 am

The pitch of the sound is strange. (NextBASIC "PLAY" statement)

Post by PiyoTaro » Sun Jun 02, 2019 9:40 am

The pitch of the sound is strange. (NextBASIC "PLAY" statement)

I have a question in the "Turbo Sound" related thread, "I want to know the value of the clock frequency of the ZX Spectrum system below 2 decimal places".

When I made a piano-like sound with NextBASIC and recorded it as a sample to compare with the output gain of 'my FM sound card'(The official wiki item "BOARD FEATURE CONTROL" has been updated at the end of May 2019, and an article "A note on partial decoding" has been added. My sound card decided to decode to a 16-bit address '$xxF7'.), the pitch of the sound was lower by half a tone.
20190602_ZXBASICPLAY_screen.jpg
20190602_ZXBASICPLAY_screen.jpg (125.14 KiB) Viewed 442 times
20190602_ZXBASICPLAY_tuner.PNG
20190602_ZXBASICPLAY_tuner.PNG (11.58 KiB) Viewed 442 times
I'm interested in the implementation error of the 'PLAY statement' in NextBASIC (128BASIC) or whether the system clock is different from the expected value.

(Core 2.00.28 Firmware v1.10e SystemClock3.5MHz)

User avatar
SevenFFF
Posts: 217
Joined: Mon Jun 05, 2017 5:30 pm
Location: USA

Re: The pitch of the sound is strange. (NextBASIC "PLAY" statement)

Post by SevenFFF » Sun Jun 02, 2019 1:26 pm

You must run at 50Hz with video timing setting 0 for accurate clock speed and pitch.
Robin Verhagen-Guest
SevenFFF / Threetwosevensixseven / colonel32
NXtel Spectron 2084blog

PiyoTaro
Posts: 176
Joined: Thu Jun 01, 2017 11:13 am

Re: The pitch of the sound is strange. (NextBASIC "PLAY" statement)

Post by PiyoTaro » Sun Jun 02, 2019 1:53 pm

SevenFFF wrote:
Sun Jun 02, 2019 1:26 pm
You must run at 50Hz with video timing setting 0 for accurate clock speed and pitch.

"TBBLUE BOOT ROM"
The launch profile is "Next (NextZxOS / Std. 48K)".
In 'Options', '60 Hz' is set to 'NO'.

In the NMI menu, the system clock is 14 MHz. 'Frequency' is '50Hz'.

User avatar
SevenFFF
Posts: 217
Joined: Mon Jun 05, 2017 5:30 pm
Location: USA

Re: The pitch of the sound is strange. (NextBASIC "PLAY" statement)

Post by SevenFFF » Sun Jun 02, 2019 2:00 pm

And this second number here is 0?

Image
Robin Verhagen-Guest
SevenFFF / Threetwosevensixseven / colonel32
NXtel Spectron 2084blog

PiyoTaro
Posts: 176
Joined: Thu Jun 01, 2017 11:13 am

Re: The pitch of the sound is strange. (NextBASIC "PLAY" statement)

Post by PiyoTaro » Sun Jun 02, 2019 5:25 pm

SevenFFF wrote:
Sun Jun 02, 2019 2:00 pm
And this second number here is 0?

Image

The default is "7".
If I change this, it may not be displayed on my HD TV.

"CONFIG FILE May 3, 2017"-HARDWARE MAIN PAGE https://www.specnext.com/config-file/


---
PiyoTaro wrote:
Sun Jun 02, 2019 1:53 pm
SevenFFF wrote:
Sun Jun 02, 2019 1:26 pm
You must run at 50Hz with video timing setting 0 for accurate clock speed and pitch.

"TBBLUE BOOT ROM"
The launch profile is "Next (NextZxOS / Std. 48K)".
In 'Options', '60 Hz' is set to 'NO'.

In the NMI menu, the system clock is 14 MHz. 'Frequency' is '50Hz'.

User avatar
SevenFFF
Posts: 217
Joined: Mon Jun 05, 2017 5:30 pm
Location: USA

Re: The pitch of the sound is strange. (NextBASIC "PLAY" statement)

Post by SevenFFF » Sun Jun 02, 2019 6:24 pm

PiyoTaro wrote:
Sun Jun 02, 2019 5:25 pm
The default is "7".
If I change this, it may not be displayed on my HD TV.
Yes, I'm afraid this is true.

HDMI timing seven has a master clock frequency of 27MHz. This is almost certainly why your note frequencies are not at concert pitch.

These are the master clock frequencies for all eight video timing modes, from the register 17 documentation (clk28 value):

Code: Select all

(R/W) 0x11 (17) => Video Timing (writable in config mode only)
bits 7-3 = Reserved, must be 0
bits 2-0 = Mode (VGA = 0..6, HDMI = 7)
000 = Base VGA timing, clk28 = 28000000
001 = VGA setting 1, clk28 = 28571429
010 = VGA setting 2, clk28 = 29464286
011 = VGA setting 3, clk28 = 30000000
100 = VGA setting 4, clk28 = 31000000
101 = VGA setting 5, clk28 = 32000000
110 = VGA setting 6, clk28 = 33000000
111 = HDMI, clk28 = 27000000
50/60Hz selection depends on bit 2 of register 0x05
The reason for this choice is long and complicated, but the simple answer is that many HDMI displays do not follow the HDMI specification. After much experimentation and testing with different displays, the clock frequency of 27MHz was chosen because it offered the most compatibility for Next users. I am sorry this is causing you problems.

As timing accuracy is important to you, you may try:
  • VGA cable using timing 0, with scandoubler on
  • RGB cable using timing 0, with scandoubler off
  • HDMI cable using timing 0 (not 7!), with scandoubler on and 50_60=1. This one should also use 28MHz master clock and may work on your display.
  • HDMI cable using alternate 128K-only FPGA core with 1xAY, which implements a full scan buffer (there is not room for full Next features in this core). Instructions here.
A suitable RGB cable can be found here. I think perhaps Japan uses EURO-SCART connector but with different pinout? In which case you may need to rewire the cable. Note that this cable may include passive components (resistors, etc).

If your TV accepts neither VGA not RGB input, you may use a cheap VGA-HDMI or RBG-HDMI convertor. Other people are using these, and they give acceptable results.
Last edited by SevenFFF on Sun Jun 02, 2019 6:48 pm, edited 9 times in total.
Robin Verhagen-Guest
SevenFFF / Threetwosevensixseven / colonel32
NXtel Spectron 2084blog

User avatar
SevenFFF
Posts: 217
Joined: Mon Jun 05, 2017 5:30 pm
Location: USA

Re: The pitch of the sound is strange. (NextBASIC "PLAY" statement)

Post by SevenFFF » Sun Jun 02, 2019 6:28 pm

Perhaps, before you buy a cable or change your display, you could run your test PLAY program without a display at timing 0? You may write your program in C:/nextzxos/autoexec.bas, so that it runs automatically on boot.
Robin Verhagen-Guest
SevenFFF / Threetwosevensixseven / colonel32
NXtel Spectron 2084blog

Post Reply