BBC BASIC for Windows
« CD-quality stereo SOUND! »

Welcome Guest. Please Login or Register.
Apr 5th, 2018, 9:56pm



ATTENTION MEMBERS: Conforums will be closing it doors and discontinuing its service on April 15, 2018.
Ad-Free has been deactivated. Outstanding Ad-Free credits will be reimbursed to respective payment methods.

If you require a dump of the post on your message board, please come to the support board and request it.


Thank you Conforums members.

BBC BASIC for Windows Resources
Online BBC BASIC for Windows documentation
BBC BASIC for Windows Beginners' Tutorial
BBC BASIC Home Page
BBC BASIC on Rosetta Code
BBC BASIC discussion group
BBC BASIC for Windows Programmers' Reference

« Previous Topic | Next Topic »
Pages: 1 2 3  4 Notify Send Topic Print
 veryhotthread  Author  Topic: CD-quality stereo SOUND!  (Read 1339 times)
rtr2
Guest
xx CD-quality stereo SOUND!
« Thread started on: Jun 6th, 2015, 10:50pm »

When BB4W was first developed (about 15 years ago) the CPU power then available was only sufficient for the SOUND/ENVELOPE emulation to generate 8-bit mono sound, at a sampling rate of 22,050 Hz. Although the resulting quality is comparable with the BBC Micro's sound output, it is obviously poor by modern standards. Nowadays, there is no such restriction.

Just for fun I have been working on a library which (quite literally) patches the code of BB4W in memory so that it generates 16-bit stereo sound at the standard CD sampling rate of 44,100 Hz. Once patched the SOUND and ENVELOPE statements work normally, except that the channel 0 'noise' facility is unavailable (only 4-voice tone output is supported). A CPU with SSE2 support is required.

I have arbitrarily put channels 0 and 1 on the left and channels 2 and 3 on the right, although the library could be extended to support panning the four SOUND channels to any required L/R mix.

I will release the library in due course, but meanwhile to give you a taster here is Bach's Brandenburg Concerto No.3 from the Yahoo group, after patching (best listened to on headphones):

http://www.rtr.myzen.co.uk/Brandenburg3_4voice_HQ.exe

Richard.
« Last Edit: Jun 7th, 2015, 9:52pm by rtr2 » User IP Logged

rtr2
Guest
xx Re: CD-quality stereo SOUND!
« Reply #1 on: Jun 8th, 2015, 12:37pm »

on Jun 6th, 2015, 10:50pm, g4bau wrote:
here is Bach's Brandenburg Concerto No.3 from the Yahoo group, after patching (best listened to on headphones)

As promised I have replaced the file with a digitally-signed version which should not trigger security warnings:

http://www.rtr.myzen.co.uk/Brandenburg3_4voice_HQ.exe

There is also a video version here, although for some reason it has only mono sound:



Richard.
User IP Logged

hitsware
Junior Member
ImageImage


member is offline

Avatar




Homepage PM

Gender: Male
Posts: 70
xx Re: CD-quality stereo SOUND!
« Reply #2 on: Jun 9th, 2015, 9:25pm »

Richard,

Since SOUND is restricted to (essentially) squarewaves,
I can't fathom that you are gaining much with increased bandwidth. (Not that it would hurt anything) and 'maybe' I can hear some difference. Do You ? Stereo would be nice.
Maybe some kind of wavefile writer as on the Amiga. Will the FREQOUT function work with your new efforts ?
You certainly are busy for someone at times so jaded smiley
As always thank You for the efforts .........................
User IP Logged

rtr2
Guest
xx Re: CD-quality stereo SOUND!
« Reply #3 on: Jun 9th, 2015, 10:16pm »

on Jun 9th, 2015, 9:25pm, hitsware wrote:
Since SOUND is restricted to (essentially) squarewaves

I don't know what makes you think that; it has never been true. Indeed when testing the HQSOUND library I did so initially with sine waves, because that made it easier to assess whether it was working correctly. I added some harmonics in later, to make the tone more interesting, but the waveform can be anything at all (Nyquist allowing).

Quote:
I can't fathom that you are gaining much with increased bandwidth.

Indeed, the increased bandwidth is an incidental advantage. It's the change from 8-bit to 16-bit sampling which, of course, makes the difference quality-wise (reducing the quantising noise from around -30 dB to better than -75 dB).

Quote:
'maybe' I can hear some difference. Do You ?

The difference is amazing, not least the stereo; the output is now indeed 'CD quality' (disregarding things like clicks from unfiltered level transitions). If you can't hear much of an improvement either your ears or your sound card/speakers need mending!

Quote:
Will the FREQOUT function work with your new efforts ?

Yes, the frequency isn't changed at all by the library - even to the extent that the lowest notes still have a pitch error rather larger than would ideally be desirable.

Quote:
You certainly are busy for someone at times so jaded

Busy? You gave me the idea by posting a program using MIDI output and the HQSOUND library was working a few hours later. The entire project took well under a day.

But I have noted the (almost) total lack of interest. In fact this forum is about as dead as BBC BASIC is - which makes sense I guess. sad

Richard.
User IP Logged

hitsware
Junior Member
ImageImage


member is offline

Avatar




Homepage PM

Gender: Male
Posts: 70
xx Re: CD-quality stereo SOUND!
« Reply #4 on: Jun 10th, 2015, 12:11am »

> I don't know what makes you think that;

Observing with oscilloscope and a knowledge of retro (chip) music production .
User IP Logged

Richey
New Member
Image


member is offline

Avatar




PM

Gender: Male
Posts: 35
xx Re: CD-quality stereo SOUND!
« Reply #5 on: Jun 10th, 2015, 05:33am »

We'll I represent the B in BASIC - using BBC BASIC for Windows and other BASICs to learn programming, which is a journey and not an event!

While there does seem to be some decline in the use of BASIC, at least on the face of it, for 'serious' applications perhaps as a result of things like Microsoft abandoning QBASIC, the current problems with PowerBASIC following the death of Bob Zale, the abandonment / non-development of open source BASICs by their authors and the non appearance of Liberty BASIC 5 (or v4.5 for that matter) etc, I still think it has a significant presence amongst hobby coders.

I follow the retro computer / coding scene and I'm amazed about how much BASIC coding goes on there by people who are knowledgable in other programming languages; for example, there are people still writing lots of games for the ZXSpectrum and even the 1k ZX81.

I still think that even given the Pythons and Lua's of this world, nothing beats BASIC as an easy to learn and flexible language that provides both a super introduction into coding for ANYONE but (at least in the case of BBC BASIC and some other BASICs) powerful and stable enough to be used to do pretty much ANYTHING!

IMHO a BBC BASIC library for easy GUI would enhance BBC BASIC and improve its potential popularity - this must be worth the time and effort. Would it be difficult to achieve for an experienced and relatively competent coder (that's not me I'm afraid!)?

User IP Logged

DDRM
Administrator
ImageImageImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 321
xx Re: CD-quality stereo SOUND!
« Reply #6 on: Jun 10th, 2015, 07:48am »

Hi Richard,

>But I have noted the (almost) total lack of interest. In fact this forum is about as dead as BBC BASIC is - which makes sense I guess.

A little harsh, perhaps! I see the thread has been read 74 times (as I write), and I am certainly looking forward to the release of the library - and it would be nice to have the panning feature - would that be dynamic - so a character could move across the screen, for example?

In the meantime, I am enjoying the Bach very much, even through my speakers. The stereo effects are very impressive!

Best wishes,

D
User IP Logged

rtr2
Guest
xx Re: CD-quality stereo SOUND!
« Reply #7 on: Jun 10th, 2015, 08:27am »

on Jun 10th, 2015, 12:11am, hitsware wrote:
Observing with oscilloscope and a knowledge of retro (chip) music production.

Observing with an oscilloscope tells you only what waveform I chose to use, not what waveform(s) it could generate. grin

As far as "knowledge of retro chip music production" goes, the fact that the original BBC Micro hardware may have been able to generate only square waves has no bearing on what a software emulation may or may not be able to do. In software, square waves are just about the most difficult thing to generate, because they contain harmonics up to infinity - sine waves are the easiest to generate!

Anyway, for the record, BB4W has always used Direct Digital Synthesis (DDS) for its SOUND output. The waveform is stored in memory (as 16 tables - one for each level setting - with 256 8-bit samples in the case of the built-in functionality and 65536 16-bit samples in the case of HQSOUND). The wave shape can be anything at all, so long as it contains no frequency components which could result in aliasing at the highest output pitch (approx. 2453 Hz, so nothing much higher than an 8th harmonic).

The wave-table generation in the HQSOUND library is simple BASIC code, and could easily be adapted to produce different waveforms. It would even be possible to adapt the library to use a different waveform for each channel and/or each level, although that's something that would need to be left as an exercise for others.

Richard.
« Last Edit: Jun 10th, 2015, 12:46pm by rtr2 » User IP Logged

Edja
Developer

member is offline

Avatar




PM


Posts: 60
xx Re: CD-quality stereo SOUND!
« Reply #8 on: Jun 10th, 2015, 08:34am »

Quote:
But I have noted the (almost) total lack of interest. In fact this forum is about as dead as BBC BASIC is
This sort of comment, sadly enough, pops up from time to time. It seems most of the forum members are working in silence. To add a positive twist : With more bugs in it (compared to other Basic's/languages) BB4W would certainly fire up more discussion and threads on the forum. Maybe BB4W is just too good a product.
Quote:
a BBC BASIC library for easy GUI would enhance BBC BASIC and improve its potential popularity
So through! I just don't have the skills to contribute to this. Otherwise I would. Really! Of course, I know, this doesn't help.

Eddy
User IP Logged

hitsware
Junior Member
ImageImage


member is offline

Avatar




Homepage PM

Gender: Male
Posts: 70
xx Re: CD-quality stereo SOUND!
« Reply #9 on: Jun 10th, 2015, 2:24pm »

>
Observing with an oscilloscope tells you only what waveform I chose to use, not what waveform(s) it could generate.
>

I know that.

>
As far as "knowledge of retro chip music production" goes, the fact that the original BBC Micro hardware may have been able to generate only square waves has no bearing on what a software emulation may or may not be able to do. In software, square waves are just about the most difficult thing to generate, because they contain harmonics up to infinity - sine waves are the easiest to generate!

Anyway, for the record, BB4W has always used Direct Digital Synthesis (DDS) for its SOUND output. The waveform is stored in memory (as 16 tables - one for each level setting - with 256 8-bit samples in the case of the built-in functionality and 65536 16-bit samples in the case of HQSOUND). The wave shape can be anything at all, so long as it contains no frequency components which could result in aliasing at the highest output pitch (approx. 2453 Hz, so nothing much higher than an 8th harmonic).
>

You've stated before that your purpose was to emulate the original system ergo the chip. I certainly did not mean to imply that as a limitation.
« Last Edit: Jun 10th, 2015, 2:24pm by hitsware » User IP Logged

David Williams
Developer

member is offline

Avatar

meh


PM

Gender: Male
Posts: 452
xx Re: CD-quality stereo SOUND!
« Reply #10 on: Jun 10th, 2015, 3:10pm »

on Jun 9th, 2015, 10:16pm, g4bau wrote:
But I have noted the (almost) total lack of interest. In fact this forum is about as dead as BBC BASIC is - which makes sense I guess. sad


I'm risking an "off topic" proclamation here, but a commercial game written entirely in BBC BASIC was published a few months ago. The game's called 'Overlord', and was written by Anthony Bartram for the RISC OS platform (the first original, commercial game for RISC OS in several years). I even bought a copy (at £9.99) - my first purchase of a computer game since perhaps 1993! I enjoyed the game. I think Anthony mentioned in an interview that it sold well at a recent RISC OS show.

(He's probably one of the few that has made any money at all from the RISC OS scene!)

http://www.amcog-games.co.uk/

'Overlord' comes with its source code, and upon inspection it wouldn't be difficult to port it over to BB4W (not that I would do such a thing myself without permission and obviously not without license agreement, even if I had the time).

Heartwarming, isn't it, to know that BBC BASIC is still being used to create commercial products. smiley


David.
--
User IP Logged

rtr2
Guest
xx Re: CD-quality stereo SOUND!
« Reply #11 on: Jun 10th, 2015, 5:35pm »

on Jun 10th, 2015, 2:24pm, hitsware wrote:
You've stated before that your purpose was to emulate the original system ergo the chip.

Just to remind you, the sound chip on the original BBC Micro was quite primitive, so things like the ENVELOPE functionality were implemented entirely in software rather than in hardware. This contrasts with some other machines of the day which used a more sophisticated chip but provided less functionality.

I look forward to seeing - and hearing - what you (and others) can achieve by modifying the HQSOUND library to support things like dynamic stereo panning, multiple waveforms and the like.

Richard.
User IP Logged

hitsware
Junior Member
ImageImage


member is offline

Avatar




Homepage PM

Gender: Male
Posts: 70
xx Re: CD-quality stereo SOUND!
« Reply #12 on: Jun 10th, 2015, 7:24pm »

User Image
User IP Logged

hitsware
Junior Member
ImageImage


member is offline

Avatar




Homepage PM

Gender: Male
Posts: 70
xx Re: CD-quality stereo SOUND!
« Reply #13 on: Jun 10th, 2015, 7:44pm »

" It contains three square wave tone generators and one white noise generator, each of which can produce sounds at various frequencies and sixteen different volume levels."

You may not give those 'primitive' chips their just due.
I strongly surmise that the original ENVELOPE addressed the various registers in the SNhuh
User IP Logged

rtr2
Guest
xx Re: CD-quality stereo SOUND!
« Reply #14 on: Jun 10th, 2015, 8:38pm »

on Jun 10th, 2015, 7:24pm, hitsware wrote:
User Image

You will get a 'Not in a subroutine' error if you RUN, rather than CALL (or INSTALL) the library. But it's quite normal for a BB4W library to report an error if you RUN it directly - indeed it's inevitable that any module designed to be CALLed will report an error if it is RUN instead - so I wonder what point you are making.

Quote:
I strongly surmise that the original ENVELOPE addressed the various registers in the SN

I think that's unlikely. Although I've never seen the relevant code in the Acorn MOS, I would expect that its structure was similar to my code in BB4W which does the same job. My envelope routine does not directly call any of the code which emulates the 'chip' (i.e. the DDS code) but achieves its effect indirectly by effectively calling the SOUND routine, to set the frequency and amplitude, every centisecond.

Richard.
« Last Edit: Jun 10th, 2015, 9:14pm by rtr2 » User IP Logged

Pages: 1 2 3  4 Notify Send Topic Print
« Previous Topic | Next Topic »

| |

This forum powered for FREE by Conforums ©
Terms of Service | Privacy Policy | Conforums Support | Parental Controls