PROC_arrayslice was added to arraylib in BBCSDL version 1.39a, release details are here. The current version is 1.40a.
Waveform Generator
-
- Posts: 272
- Joined: Tue 18 Jun 2024, 09:32
Re: Waveform Generator
In case it's of interest, here's a version of the sawtooth program which uses PROC_pcopy instead of PROC_arrayslice; this may improve its compatibility (PROC_pcopy was added in BBCSDL 1.37a), but at the cost of running a little more slowly:Richard Russell wrote: ↑Tue 28 Jan 2025, 10:07 PROC_arrayslice was added to arraylib in BBCSDL version 1.39a
Code: Select all
REM Synthesise a sawtooth waveform from its Fourier series
REM By Richard Russell, inspired by a program by MrHiggins
MODE 8
INSTALL @lib$ + "arraylib"
DIM a(320 * 640), s(639), t(639)
REM Construct harmonics up to Nyquist limit:
P% = 0
FOR H% = 0 TO 319
FOR I% = -320 TO 319
a(P%) = SIN(2 * PI * H% * I% / 640)
P% += 1
NEXT
NEXT H%
REM Build sawtooth from Fourier series:
*REFRESH OFF
FOR H% = 1 TO 319
CLS
PROC_pcopy(a(), t(), 0, H% * 640, 640)
a = (-1) ^ H%
t() *= a / H%
s() += t()
FOR I% = 0 TO 639
GCOL 15
PLOT I% * 2, t(I%) * 300 + 512
GCOL 9
PLOT I% * 2, s(I%) * 300 + 512
NEXT
*REFRESH
NEXT H%
*REFRESH ON
-
- Posts: 272
- Joined: Tue 18 Jun 2024, 09:32
Re: Waveform Generator
I did a speed comparison (with the 'wait for vsync' removed):
PROC_arrayslice (BBCSDL): 0.73 seconds
PROC_pcopy (BBCSDL): 0.73 seconds
PROC_pcopy (BB4W): 12.5 seconds
Plotting dominates the time, so PROC_pcopy being slower than PROC_arrayslice made no significant difference to the overall duration. However, BB4W was about 17-times slower than BBCSDL!

(Incidentally neither Repton nor DDRM seems to have seen my replies. I'm guessing this is probably because they have both added me to their Foes list, which blocks notifications and hides messages).
-
- Posts: 14
- Joined: Mon 17 Jun 2024, 08:02
Re: Waveform Generator
Hi Richard,
Of course I haven't added you to a foes list! And I have seen your response, and noted that I need to update my version of BBC-SDL. Is an updated library available for BB4W, and/or will the updated SDL version work in BB4W?
Currently mainly working in R...
Best wishes,
D
Of course I haven't added you to a foes list! And I have seen your response, and noted that I need to update my version of BBC-SDL. Is an updated library available for BB4W, and/or will the updated SDL version work in BB4W?
Currently mainly working in R...

Best wishes,
D
-
- Posts: 272
- Joined: Tue 18 Jun 2024, 09:32
Re: Waveform Generator
No, it depends on changes to the core interpreter. You could copy PROC_pcopy() into your BB4W program, but what would be the point? I've already noted that the code runs about 17-times more slowly in BB4W so it makes much more sense to run it in BBCSDL.
Although I have no plans to discontinue, or to remove support for, BB4W it is reliant on Windows continuing to run 32-bit apps (and updates not breaking it). Windows is just about the only major OS which hasn't fully migrated to 64-bits.
I've discussed extensively what would be involved in accessing the Windows GUI (native dialogue boxes etc.) from BBCSDL, and have suggested that libraries to support this be developed so that there's an alternative if BB4W does stop working. It's not my fault that nobody has (yet) done so!