User avatar
RichardRussell
Posts: 1309
Joined: Thu Jun 21, 2012 10:48 am

Re: Introduction to BBC BASIC

Tue Feb 08, 2022 4:50 pm

hitsware wrote:
Tue Feb 08, 2022 3:46 pm
It would be nifty ( on the Pico ) if the PWM channels could be used for the voices .
They can, of course; what made you think otherwise? :?

As I said earlier, the nice thing about the PWM channels on the Pico is that they accept the same PCM audio format as is used in BBC BASIC for SDL 2.0, so I've simply ported the code from there, with virtually no modifications. As a result SOUND, ENVELOPE, *TEMPO, *STEREO and *VOICE work exactly as they do in BBCSDL.
Who designed the SOUND system as used in BBCBasic ?
Back in 1981 you mean? I don't know exactly who it was, it might have been Paul Bond who was in charge of the Machine Operating System (MOS) for Acorn at the time.
Then there is the SOUND used in the BBCBasic with the RiscOS ?
RISC OS sound being somewhat different from the BBC Micro has always been a mystery to me. It's true that Acorn's Archimedes didn't have the SN76489 chip, but I expect it could easily have been emulated in software then just as I do now.

Particularly strange is that ARM BBC BASIC has the ENVELOPE statement but it does nothing, even though in the BBC Micro it was entirely implemented in software anyway!

From my (admittedly biased) perspective, Acorn somewhat lost their way once the BBC was no longer actively involved with the specification of the hardware and software of their machines - but of course I would say that!

Certainly when I started to develop BBC BASIC for Windows, 22 years ago now, I was in no doubt that it should emulate the BBC Micro's sound, not RISC OS sound.

User avatar
hitsware
Posts: 359
Joined: Sat Mar 26, 2016 10:12 pm
Location: sacramento , california , usa

Re: Introduction to BBC BASIC

Tue Feb 08, 2022 7:38 pm

RichardRussell wrote:
Tue Feb 08, 2022 4:50 pm
They can, of course; what made you think otherwise? :?
I mean :
Rather than use some high frequency ' carrier '
to produce the waves with PWM , ..............
The PWM signal itself would be the wave signal .
SOUND channel , pulse width, envelope , frequency , duration
or *PULSEWIDTH channel , percent

FWIW :
SETPIN pin, PWMnx Allocate pin to PWMnx
'n' is the PWM number (0 to 7) and 'x' and is the channel (A or B)
The setpin can be changed until the PWM command is issued. At that point
the pin becomes locked to PWM until PWMn,OFF is issued.

Pulse Width Modulation
The PWM (Pulse Width Modulation) command allows the PicoMite to generate square waves with a program
controlled duty cycle. By varying the duty cycle you can generate a program controlled voltage output for use
in controlling external devices that require an analog input (power supplies, motor controllers, etc). The PWM
outputs are also useful for driving servos and for generating a sound output via a small transducer.
The PWM outputs consists of up to 8 channels (numbered 0 to 7) with each channel having two outputs (A and
B). For each channel the frequency can be selected and for each output a different duty cycle can be set.
Up to 16 pins can be configured as PWM outputs using the SETPIN command.
http://www.hitswares.com/

User avatar
RichardRussell
Posts: 1309
Joined: Thu Jun 21, 2012 10:48 am

Re: Introduction to BBC BASIC

Tue Feb 08, 2022 8:30 pm

hitsware wrote:
Tue Feb 08, 2022 7:38 pm
Rather than use some high frequency ' carrier ' to produce the waves with PWM , ..............
The PWM signal itself would be the wave signal .
I'm afraid that doesn't make much sense to me. You seem to be proposing replacing a method which is capable of outputting any waveform at not far short of CD quality, with one capable of outputting only square waves. What on earth would be the point of that?

Perhaps you'd be happier with Bill's GUI version, which is limited to emulating the SN76489 because core 1 is fully occupied with generating video, so can only produce BBC Micro-quality sound. Even so, he can still generate three notes (plus noise) at once, which yours can't.

User avatar
hitsware
Posts: 359
Joined: Sat Mar 26, 2016 10:12 pm
Location: sacramento , california , usa

Re: Introduction to BBC BASIC

Tue Feb 08, 2022 9:05 pm

RichardRussell wrote:
Tue Feb 08, 2022 8:30 pm
What on earth would be the point of that?
An elegant experiment . ( Assuming music production only ( NOT reproduction )

In the case of the Pico, the PWM lines are implemented using special PWM hardware. It has eight PWM generators, each capable of two PWM outputs. Any of the GPIO lines can be used as PWM lines and this means you can have up to 16 PWM lines in operation at any given time. Things are a little more complicated in that each pair of outputs has the same frequency, which means you have eight, independently set, pairs of outputs. In addition, one of the outputs can be used as an input and this reduces the number of outputs available.

You would have 8 frequencies , each with the possibility of 2 pulse widths
Varying pulse width can produce quite a range of timbre .
http://www.hitswares.com/

User avatar
RichardRussell
Posts: 1309
Joined: Thu Jun 21, 2012 10:48 am

Re: Introduction to BBC BASIC

Tue Feb 08, 2022 10:16 pm

hitsware wrote:
Tue Feb 08, 2022 9:05 pm
You would have 8 frequencies , each with the possibility of 2 pulse widths
Varying pulse width can produce quite a range of timbre .
All true, but you can create something which is acoustically identical using just one PWM output (within the limitation of the 16 kHz sampling, which could be higher at the expense of amplitude resolution)!

This is basic sampling theory: any waveform whatsoever - even if it has 8 distinct fundamental frequencies each with a different set of harmonics, which is all "varying pulse width" is - can be sampled and reproduced, so long as the highest frequency it contains is less than half the sampling frequency.

So, from my perspective, using up 16 GPIO outputs to generate a signal which could be generated using just one is wasteful. And those 16 outputs can still only generate a very limited range of sounds, whilst the single PWM output can generate virtually anything.

User avatar
hitsware
Posts: 359
Joined: Sat Mar 26, 2016 10:12 pm
Location: sacramento , california , usa

Re: Introduction to BBC BASIC

Wed Feb 09, 2022 1:27 am

Anyways , You get the ' Maintainer of the Most Musical Basic ' award for 2022 ! ..... : )

Code: Select all

      DIM nn(192),c(3),m(3),o(3),p(15)
      *voice 1,3: *voice 2,3:  *voice 3,6

      ENVELOPE 1,0,0,0,0,0,0,0,120,-1,0,0,110,0
      ENVELOPE 2,0,0,0,0,0,0,0,120,-5,0,0,090,0
      ENVELOPE 3,0,0,0,0,0,0,0,120,-2,0,0,090,0
      ENVELOPE 4,0,0,0,0,0,0,0,120,-9,0,0,000,0
      ENVELOPE 5,0,0,0,0,0,0,0,120,-9,0,0,070,0
      ENVELOPE 6,0,0,0,0,0,0,0,120,-9,0,0,080,0
      ENVELOPE 7,0,0,0,0,0,0,0,120,-9,0,0,090,0

      FOR j=0 TO 192
        nn(j)=INT(48*(LOG(j)/LOG(2))+0.5)-168
      NEXT j
      FOR x=0 TO 3: READ c(x): NEXT x
      FOR x=0 TO 3: READ m(x): NEXT x
      FOR x=1 TO 3: READ o(x): NEXT x
      FOR x=0 TO 7: READ p(x): NEXT x
      DATA 8,6,9,6, 2,4,3,4, 1,2,4
      DATA 6,4,5,5,7,4,5,5

      FOR x=0 TO 3: SOUND 0,7,4,12: NEXT x
      WAIT 240

      REPEAT: FOR x=0 TO 3
          SOUND 1,-7,nn(2*c(x)),24
          SOUND 2,-7,nn(3*c(x)),24
          FOR y=0 TO 3: r=RND(3)
            SOUND 3,r,nn(c(x)*m(y)*o(r)),6
            FOR a=0 TO 1: z=((2*y)+a): SOUND 0,p(z),4,3
            NEXT a: NEXT y: NEXT x: UNTIL FALSE
Another octave at the bottom would help a lot .
Maybe even ( cringe ) switch to MIDI notes ? .....
http://www.hitswares.com/

User avatar
RichardRussell
Posts: 1309
Joined: Thu Jun 21, 2012 10:48 am

Re: Introduction to BBC BASIC

Wed Feb 09, 2022 9:36 am

hitsware wrote:
Wed Feb 09, 2022 1:27 am
Another octave at the bottom would help a lot .
I already lowered it by an octave compared with the BBC Micro, the lowest note available is 62.63 Hz. As you may be aware, with DDS (Direct Digital Synthesis) the frequency accuracy gets worse the lower the frequency you are generating.
Maybe even ( cringe ) switch to MIDI notes ?
MIDI note values don't allow you to play frequencies between the semitones of the regular scale so you cannot create a smooth glissando effect. Because the sound system on the BBC Micro was intended for sound effects (e.g. in games) just as much as for music, it was felt that quarter-semitone steps were the best choice.

User avatar
RichardRussell
Posts: 1309
Joined: Thu Jun 21, 2012 10:48 am

Re: Introduction to BBC BASIC

Thu Feb 10, 2022 4:47 pm

I have released version 1.28a of BBC BASIC for SDL 2.0 - the cross-platform programming language for Windows, Mac OS, Linux, Raspberry Pi OS, Android, iOS and in-browser. The changes in this version are as follows:

  1. BASIC Interpreter / Run Time Engine

    Updated SDL2_ttf to version 2.0.18 (Windows edition only); note that this changes the appearance of some fonts, especially in small sizes.

    ARM and 64-bit versions brought into line with 32-bit x86 versions in a couple of minor respects.

  2. IDEs and Utilities

    Updated about.bbc to be compatible with SDL2_ttf version 2.0.18 or later (in reporting the version of FreeType).

  3. Libraries

    Updated imglib.bbc to support displaying animated GIFs (there is an updated BB4W library too).

    Updated gfxlib.bbc to include PROC_gfxGaussianBlur3x3 (also updated gfxlib_docs.pdf).

    Updated dlglib.bbc to behave better with SDL2_ttf version 2.0.18 or later.

  4. Example Programs

    Added anigif.bbc (in examples/graphics) to illustrate displaying an animated GIF.

    Modified telstar.bbc so that F11 sends a carriage-return character to the line.
This version may be downloaded, for all the supported platforms, from the usual location. The GitHub repository has been updated (used to build the MacOS, Raspberry Pi, Android, iOS, 64-bit Linux and in-browser editions, currently).

User avatar
RichardRussell
Posts: 1309
Joined: Thu Jun 21, 2012 10:48 am

Re: Introduction to BBC BASIC

Fri Feb 11, 2022 3:51 pm

Here's another demo of sound from the Raspberry Pi Pico, this time of Scott Joplin's Ragtime classic 'The Entertainer'. This particularly illustrates the capabilities of BBC BASIC's ENVELOPE statement in simulating a piano-like sound, with Attack, Decay, Sustain and Release phases. The transcription for computer music was by Phil Wheeler and Tina Parkhouse in August 1982:

https://www.youtube.com/watch?v=mToUlCzmg7w

User avatar
RichardRussell
Posts: 1309
Joined: Thu Jun 21, 2012 10:48 am

Re: Introduction to BBC BASIC

Fri Feb 11, 2022 10:14 pm

I note that the 64-bit Raspberry Pi OS is now out of beta so can I take the opportunity to mention that both BBC BASIC for SDL 2.0 and the Console Mode edition are available for 64-bit Pi OS.

User avatar
hitsware
Posts: 359
Joined: Sat Mar 26, 2016 10:12 pm
Location: sacramento , california , usa

Re: Introduction to BBC BASIC

Sat Feb 12, 2022 3:15 am

RichardRussell wrote:
Fri Feb 11, 2022 3:51 pm
This particularly illustrates the capabilities of BBC BASIC's ENVELOPE statement in simulating a piano-like sound,
with Attack, Decay, Sustain and Release phases.
Have You , or do You , hear any differances in the sound
of BBCBasic in differant situations ?
I . E ..... OS ' s , hardwares , etc ?
http://www.hitswares.com/

User avatar
RichardRussell
Posts: 1309
Joined: Thu Jun 21, 2012 10:48 am

Re: Introduction to BBC BASIC

Sat Feb 12, 2022 10:01 am

hitsware wrote:
Sat Feb 12, 2022 3:15 am
Have You , or do You , hear any differances in the sound
of BBCBasic in differant situations ?I . E ..... OS ' s , hardwares , etc ?
Obviously there are differences, yes. Every component (the application, the OS, the hardware) contributes to the overall sound. There are going to be major factors, such as sampling rate and quantising, and minor ones such as distortion, reconstruction filter performance and so on.

User avatar
RichardRussell
Posts: 1309
Joined: Thu Jun 21, 2012 10:48 am

Re: Introduction to BBC BASIC

Fri Mar 18, 2022 6:08 pm

I have updated the Console Mode editions of BBC BASIC to version 0.41. The changes in this version are:

  • Added support for serial I/O, for example the EXT# function returns the number of characters waiting in the input buffer.

  • Added a new example program animal.bbc which is the famous 'guess the animal' program, which learns from its mistakes (sort of).
Version 0.41 may be downloaded from the usual place.

User avatar
RichardRussell
Posts: 1309
Joined: Thu Jun 21, 2012 10:48 am

Re: Introduction to BBC BASIC

Sat Mar 19, 2022 8:45 pm

Should anybody be interested, I have written a Wiki article here about Lambdas (anonymous functions) in BBC BASIC.

User avatar
RichardRussell
Posts: 1309
Joined: Thu Jun 21, 2012 10:48 am

Re: Introduction to BBC BASIC

Sat Mar 26, 2022 10:49 pm

I have released version 1.29a of BBC BASIC for SDL 2.0 - the cross-platform programming language for Windows, Mac OS, Linux, Raspberry Pi OS, Android, iOS and in-browser. The changes in this version are as follows:

  1. BASIC Interpreter / Run Time Engine

    Added support for Serial I/O (e.g. EXT# returning the number of bytes waiting in a serial input buffer).

    Fixed a minor graphics bug which could cause fill operations to fail if an odd-value relative coordinate was supplied.

  2. IDEs and Utilities

    Updated searchin.bbc to avoid it being confused by an Acorn-format tokenised program.

    Improved error reporting if SDLIDE.bbc fails to create a temporary file.

  3. Libraries

    Optimised aagfxlib by calling SDL2 API functions by address rather than by name.

  4. Example Programs

    Added conway.bbc (in examples/general), a version of Conway's Game of Life in which the calculations are performed by the GPU.

    Added video.bbc (in examples/general) as a proof-of-principle demonstration of playing a video, albeit uncompressed and with no sound.
Important note for Android users: the Code Signing Certificate has been updated, and because the company from which I have previously obtained them has closed down the new certificate has a different ID. You will need to uninstall BBC BASIC before you can install v1.29a; take care to backup (e.g. to a PC) anything you need in @usr$.

This version may be downloaded, for all the supported platforms, from the usual location. The GitHub repository has been updated (used to build the MacOS, Raspberry Pi, Android, iOS, 64-bit Linux and in-browser editions, currently).

User avatar
RichardRussell
Posts: 1309
Joined: Thu Jun 21, 2012 10:48 am

Re: Introduction to BBC BASIC

Sun Apr 10, 2022 4:39 pm

You may have noticed a minor regression in version 1.29a: the appearance of radiobuttons was accidentally affected. Although only cosmetic, if you want to fix this defect the files at the website have been updated (the dlglib library has been changed); simply download and install the new version.

User avatar
RichardRussell
Posts: 1309
Joined: Thu Jun 21, 2012 10:48 am

Re: Introduction to BBC BASIC

Sun May 08, 2022 11:05 am

I have released version 1.30a of BBC BASIC for SDL 2.0 - the cross-platform programming language for Windows, Mac OS, Linux, Raspberry Pi OS, Android, iOS and in-browser. The changes in this version are as follows:

  1. BASIC Interpreter / Run Time Engine

    OS Filing System errors now update the SDL error string, for the convenience of BASIC programs.

    iOS edition only: Reduced size of the back button on iPads.

    iOS edition only: Reinstated the ability to create a home screen icon to run a specific BASIC program (which stopped working at some point).

  2. IDEs and Utilities

    The Compile utility no longer quits if an embedded file cannot be found.

    Touch IDE: The background may now be selected from a choice of eight colours.

    Android and iOS only: added the ability to disable or enable fullscreen mode.

  3. Libraries

    Updated gfxlib to accept negative inter-character spacing values (@vdu.w.d&).

  4. Example Programs

    Added bugs.bbc (in examples/games), written by David Williams in 2006 based on the Flash game Ladybug Sumo.

    Added pageturn.bbc (in examples/graphics) which is a BBCSDL conversion of the old BB4W demo.
This version may be downloaded, for all the supported platforms, from the usual location. The GitHub repository has been updated (used to build the MacOS, Raspberry Pi, Android, iOS, 64-bit Linux and in-browser editions, currently).

User avatar
RichardRussell
Posts: 1309
Joined: Thu Jun 21, 2012 10:48 am

Re: Introduction to BBC BASIC

Sat Jun 18, 2022 7:57 pm

I have released version 1.31a of BBC BASIC for SDL 2.0 - the cross-platform programming language for Windows, Mac OS, Linux, Raspberry Pi OS, Android, iOS and in-browser. The changes in this version are as follows:

  1. BASIC Interpreter / Run Time Engine

    Updated the bundled stb_image library to version 2.2.7.

    (Windows and MacOS editions only) Updated the bundled SDL library to version 2.0.22.

    (Windows and MacOS editions only) Updated the bundled SDL_ttf library to version 2.0.18, which includes FreeType version 2.10.4.

  2. IDEs and Utilities

    Updated compiler.bbc to allow the selection of multiple embedded files.

    Updated SDLIDE.bbc to ensure compatibility with SDL version 2.0.22.

  3. Libraries

    Extended dlglib.bbc to support multiple-selection listboxes (LBS_MULTIPLESEL or LBS_EXTENDEDSEL style).

    Extended filedlg.bbc to support the selection of multiple files.

    Updated pdflib.bbc to ensure compatibility with SDL2_ttf version 2.0.18.

  4. Example Programs

    Added pdfdemo.bbc (in examples/general) to demonstrate creating a PDF file.

    Updated the list of available videotex services in telstar.bbc.

    Fixed a minor bug in pageturn.bbc affecting the shading of the 'fold'.
This version may be downloaded, for all the supported platforms, from the usual location. The GitHub repository has been updated (used to build the MacOS, Raspberry Pi, Android, iOS, 64-bit Linux and in-browser editions, currently).

User avatar
RichardRussell
Posts: 1309
Joined: Thu Jun 21, 2012 10:48 am

Re: Introduction to BBC BASIC

Sat Aug 20, 2022 4:22 pm

I have released version 1.32a of BBC BASIC for SDL 2.0 - the cross-platform programming language for Windows, Mac OS, Linux, Raspberry Pi OS, Android, iOS and in-browser. The changes in this version are as follows:

  1. BASIC Interpreter / Run Time Engine

    Fixed a minor issue affecting returned ON MOUSE coordinates when @panx% is negative.

  2. IDEs and Utilities

    Updated SDLIDE to support keyword abbreviations (but you are recommended not to use them!).

  3. Libraries

    Added mysqllib.bbc for queryimg a MySQL database (not compatible with the in-browser edition).

  4. Example Programs

    Added mysqldem.bbc (in examples/general) to demonstrate the mysqllib library by querying a public database.
This version may be downloaded, for all the supported platforms, from the usual location. The GitHub repository has been updated (used to build the MacOS, Raspberry Pi, Android, iOS, 64-bit Linux and in-browser editions, currently).

User avatar
RichardRussell
Posts: 1309
Joined: Thu Jun 21, 2012 10:48 am

Re: Introduction to BBC BASIC

Fri Oct 28, 2022 9:51 pm

I have released version 1.33a of BBC BASIC for SDL 2.0 - the cross-platform programming language for Windows, Mac OS, Linux, Raspberry Pi OS, Android, iOS and in-browser. The changes in this version are as follows:

  1. BASIC Interpreter / Run Time Engine

    The *FLOAT 80 command has been enabled in ARM editions, because although they do not support 80-bit floats the
    command is needed to be able to write a 64-bit integer to a data file without loss of precision.

  2. IDEs and Utilities

    Fixed compiler.bbc failing to upload a web bundle for testing, more than once per session.

  3. Libraries

    Added FN_readlinesocketM() to socklib.bbc, for use when multiple concurrent connections are open.

  4. Example Programs

    Modified Ceefax.bbc to restore functionality of the Sport index after a change to the BBC website.
This version may be downloaded, for all the supported platforms, from the usual location. The GitHub repository has been updated (used to build the MacOS, Raspberry Pi, Android, iOS, 64-bit Linux and in-browser editions, currently).

User avatar
RichardRussell
Posts: 1309
Joined: Thu Jun 21, 2012 10:48 am

Re: Introduction to BBC BASIC

Mon Nov 21, 2022 12:11 pm

Slightly off-topic, but there may well be people out there with both a Raspberry Pi and an iOS device. I'm pleased to announce that BBC BASIC for SDL 2.0 is now in the iOS App Store (search for 'bbcbasic') so it is no longer necessary to use the inconvenient Ad Hoc distribution mechanism. This is highly compatible with the Raspberry Pi edition (slightly more so with 64-bit PiOS than 32-bit) and most programs should run identically, although of course it will be necessary to ensure they can be controlled from a touchscreen.

AppStore.png
AppStore.png (97.4 KiB) Viewed 198 times

Return to “Other programming languages”