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

Welcome Guest. Please Login or Register.
Apr 5th, 2018, 11:16pm



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 1365 times)
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

hitsware
Junior Member
ImageImage


member is offline

Avatar




Homepage PM

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

> so I wonder what point you are making.

I obviously don't know where to put it .............
It should be filed where to be called ?
User IP Logged

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

on Jun 10th, 2015, 9:09pm, hitsware wrote:
I obviously don't know where to put it ... It should be filed where to be called ?

When you are running your program from the BB4W IDE it really doesn't matter where you store the library, so long as you specify the appropriate absolute or relative path when you CALL it. In that respect it's like any other 'resource' file used by your program.

But when it comes to compiling your program to an EXE it is obviously much more convenient if you can embed the library file in the executable, which means that it must either be in the LIB folder (which you access using @lib$) or in the same folder as your program (which you access using @dir$), or in a sub-directory of one of those places.

It is conventional to store libraries in the former location (hence the name LIB), although since that's a 'protected' folder in Windows Vista and later you will need to have administrative privileges in order to copy it there. Assuming UAC is enabled, and you copy the file in Windows Explorer (e.g. using copy-and-paste) you will be automatically prompted to grant the necessary privileges.

As is explained in the REMarks within the file itself, you can either use INSTALL (followed by a PROC_hqinit), as you would for a conventional library, or alternatively - because HQSOUND doesn't need to be resident in memory after it has done the patching - you can use CALL instead. The CALL method is particularly useful for those running the trial version of BB4W because it is more memory-efficient.

Because it's the simplest method, when modifying any of my existing four-voice music programs to use the library I simply add this at or near the start:

Code:
      CALL @lib$+"HQSOUND" 

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 #17 on: Jun 11th, 2015, 01:14am »

Maybe I am becoming deaf ......
No effect for me ... REM CALL or not
Copied file to C/programfiles/bbcbasic/lib
Code:

      CALL @lib$+"HQSOUND"

      *TEMPO 133

      ENVELOPE 1,0,0,0,0,0,0,0,127,0,0,0,40,0
      ENVELOPE 2,0,0,0,0,0,0,0,127,-3,0,0,120,0
      ENVELOPE 3,0,0,0,0,0,0,0,127,-127,0,0,100,0
      ENVELOPE 4,0,0,0,0,0,0,0,0,0,0,0,0,0

      DIM orgn(11), bass(7), drum(7)

      FOR x=0 TO 11: READ orgn(x): NEXT x
      FOR x=0 TO 7: READ bass(x): NEXT x
      FOR x=0 TO 7: READ drum(x): NEXT x

      REPEAT
        FOR x=0 TO 11: FOR y=0 TO 7
            SOUND 0,1,orgn(x)+48,4
            SOUND 1,1,orgn(x)+76,4
            SOUND 2,bass(y),orgn(x),4
            SOUND 3,drum(y),140,4
          NEXT y: NEXT x
      UNTIL FALSE: END

      DATA 32,24,4,32, 4,4,4,4, 24,24,4,4
      DATA 2,4,4,2, 2,4,4,4
      DATA 4,4,3,4, 4,4,3,4


 
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