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

dfeugey
Guest
xx Re: CD-quality stereo SOUND!
« Reply #18 on: Jun 11th, 2015, 09:17am »

Quote:
It seems most of the forum members are working in silence.

I confirm.

I hope to revive BBC Basic use in France, with some actions not completely related to www.riscos.fr (more a mix of BBC Basic for RISC OS AND Windows).

Quote:
I'm risking an "off topic" proclamation here

And we don't forget your work too smiley

Quote:
Maybe I am becoming deaf ......

Yes, it sounds the same with or without the lib. Strange.
User IP Logged

rtr2
Guest
xx Re: CD-quality stereo SOUND!
« Reply #19 on: Jun 11th, 2015, 09:40am »

on Jun 11th, 2015, 01:14am, hitsware wrote:
Maybe I am becoming deaf ......

To me the reduction in quantising noise (by more than 40 dB) is dramatic and the stereo effect unmistakable.

In all seriousness if you can't hear any difference (not even that channels 0 & 1 are left-only and channels 2 & 3 right-only) then I would worry about your hearing - or your PC.

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 #20 on: Jun 11th, 2015, 2:11pm »

Quote:
In all seriousness if you can't hear any difference (not even that channels 0 & 1 are left-only and channels 2 & 3 right-only) then I would worry about your hearing - or your PC.


Playing the code I submitted with my last post ?
User IP Logged

rtr2
Guest
xx Re: CD-quality stereo SOUND!
« Reply #21 on: Jun 11th, 2015, 3:52pm »

on Jun 11th, 2015, 2:11pm, hitsware wrote:
Playing the code I submitted with my last post ?

I haven't run that code, but something far simpler is adequate to demonstrate the stereo effect:

Code:
      CALL @lib$+"HQSOUND"
      SOUND 1, 0, 0, 10
      SOUND 2, 0, 0, 30
      SOUND 1, -15, 148, 20
      SOUND 2, -15, 168, 20 

That plays a C on the left stereo channel (only) followed by an F on the right channel (only).

But really the stereo aspect is just a (useful) side-effect. The principal objective of the library was to achieve 16-bit rather than 8-bit output, to eliminate the quantising distortion which I've always found unpleasant. Whilst you can guarantee that any modern PC will support 44.1 kHz 16-bit stereo, you can't be so certain that it will support mono with the same parameters.

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 #22 on: Jun 11th, 2015, 4:09pm »

> I haven't run that code,

Would you please ? .... Then comment on the effects ...

edit:

1) raised speakers off floor and out of corners somewhat
2) turned off EQ
3) completely closed BB4W between comparisons

Now I can hear the L-R 'ness but quieter ?
Tis true my ears are worn, plus I've noticed as my PC's go down in size (and price) the sound quality also declines. Makes sense realizing a SB card uses @ least 12 V, while the MB circuit is probably 3.3V or even 1.8V nowdays ...
« Last Edit: Jun 11th, 2015, 5:46pm by hitsware » User IP Logged

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

on Jun 11th, 2015, 4:09pm, hitsware wrote:
Would you please ? .... Then comment on the effects ...

Effects? It plays fine, with what you call 'bass' and 'drum' at 100% right channel and what passes for the 'melody' at 100% left channel. It's also free from the horrible raspy quantising noise that accompanies it when played without HQSOUND (you must restart BB4W for that of course).

Listen to them yourself:

http://www.rtr.myzen.co.uk/standard.wav
http://www.rtr.myzen.co.uk/hqsound.wav

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 #24 on: Jun 11th, 2015, 5:54pm »

Gotcha ... Thanks .... See edit to last post ....
User IP Logged

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

on Jun 11th, 2015, 4:09pm, hitsware wrote:
Now I can hear the L-R 'ness but quieter ?

The reduced level is intentional, because with the hugely increased dynamic range there's no need to risk clipping. But that's settable with the 'stereo mix' QWORD in the library so you are free to bump the level up, or play with panning, or whatever.

As I said before the library lacks any 'frills'; tweak it, enhance it, play with it - the code is very amenable to user-modification and that's the way I increasingly want to go as my own interests and abilities wane.

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 #26 on: Jun 11th, 2015, 6:22pm »

By "quieter ?" I meant I don't know about the noise you refer to ?

Moving along :
Code:
      FOR ALD = -10 TO -1
        CLS
        PRINT "ALD = ";ALD
        FOR duration = 3 TO 10
          ENVELOPE 1,0,0,0,0,0,0,0,127,ALD,0,0,126,0
          SOUND 1,1,4,duration
        NEXT duration
      NEXT ALD
      END
      REM As ALD decreases it does not take the level
      REM all the way down ......
      REM Shouldn't it ?

 
User IP Logged

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

on Jun 11th, 2015, 6:22pm, hitsware wrote:
As ALD decreases it does not take the level all the way down ...... Shouldn't it ?

You have:

Code:
          ENVELOPE 1,0,0,0,0,0,0,0,127,ALD,0,0,126,0
          SOUND 1,1,4,duration 

so the final level should be approximately:

Code:
126 + duration * tempo * ALD 


So with duration=10 and ALD=-1 (and assuming the default tempo of 5) the final level should be around 126-50=76 (or 9 on the 0-15 scale). Isn't that what you are finding?

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 #28 on: Jun 11th, 2015, 8:25pm »

How do I make the envelope go to 0 ?

Adding - numbers to AS does nothing .. ?
Likewise AR
User IP Logged

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

on Jun 11th, 2015, 8:25pm, hitsware wrote:
How do I make the envelope go to 0 ?

You need to increase the duration to give it time to decay:

Code:
      AD = -1
      duration = 25
      ENVELOPE 1,0,0,0,0,0,0,0,127,AD,0,0,126,0
      SOUND 1,1,100,duration 

But that's too obvious, so did you mean something else?

Quote:
AS does nothing .. ?

It works for me. For example here the note initially decays quickly at the AD rate but 10 centiseconds later switches to decaying at the slower AS rate:

Code:
      AD = -5
      AS = -1
      ALA = 125
      ALD = 75
      duration = 2 + 15
      ENVELOPE 1,0,0,0,0,0,0,0,127,AD,AS,0,ALA,ALD
      SOUND 1,1,100,duration 

Check on an oscilloscope if you want to see it more clearly. You may want to add an initial delay to avoid the sound start-up transient partially masking the effect.

Quote:
Likewise AR

Again it has always worked for me. I thought you were something of an expert on the ADSR envelope so I'm surprised you are having problems with it.

Richard.
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