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

Welcome Guest. Please Login or Register.
Apr 5th, 2018, 10:25pm



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

hitsware
Junior Member
ImageImage


member is offline

Avatar




Homepage PM

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

Here I (empiricly) got the envelopes to work to my liking, but at the expense of the channel modifiers (which I never understood and now do even less)
Code:
      ENVELOPE 1,0,0,0,0,0,0,0,127,0,0,-2,127,0
      ENVELOPE 2,0,0,0,0,0,0,0,127,0,0,-4,127,0
      ENVELOPE 3,0,0,0,0,0,0,0,127,0,0,-6,127,0

      DIM note(3,7),selection(16)

      FOR x=1 TO 16: READ selection(x): NEXT x
      DATA 32,40,48,60,68,0,0,0,0,0,0,0,0,0,0,0

      REPEAT
        FOR count=0 TO 7
          FOR voice=0 TO 3
            random1=RND(5)
            random2=RND(16)
            IF random1=1 THEN note(voice,count)=selection(random2)
          NEXT voice
    
          IF SGN(note(1,(count)))=1 THEN
            SOUND 1,1,note(1,(count)),1: SOUND 4097,1,0,4
          ELSE SOUND 4097,1,0,5
          ENDIF
          IF SGN(note(2,(count)))=1 THEN
            SOUND 2,1,note(2,(count)),1: SOUND 4098,1,0,4
          ELSE SOUND 4098,1,0,5
          ENDIF
          IF SGN(note(3,(count)))=1 THEN
            SOUND 3,1,note(3,(count)),1: SOUND 4099,1,0,4
          ELSE SOUND 4099,1,0,5
          ENDIF
    
        NEXT count
      UNTIL FALSE

 
User IP Logged

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

on Jun 11th, 2015, 6:22pm, hitsware wrote:
I meant I don't know about the noise you refer to ?

http://en.wikipedia.org/wiki/Quantization_%28signal_processing%29#Quantization_noise_model

User IP Logged

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

on Jun 11th, 2015, 10:21pm, hitsware wrote:
the channel modifiers (which I never understood and now do even less)

Well, since the rather vital release phase of the ADSR envelope cannot be used at all without the 'modifiers', can I politely and gently suggest that it would be helpful if you did understand them. smiley

I've checked the descriptions of those bits in the BB4W manual and I can't see how they could be made any clearer. The hold bit H, which is the one that causes the release phase of the envelope to be entered, is particularly easy to understand because the amplitude and pitch parameters are ignored!

It's also worth pointing out that the bits work exactly as they did on the BBC Micro 33 years ago, so they are not exactly 'new fangled'. grin

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

>can I politely and gently suggest
>that it would be helpful if you did
>understand them.

Your manners and sweet disposition are appreciated, but most times accompanied by an over optimistic view of my abilities .............. smiley
« Last Edit: Jun 12th, 2015, 01:05am by hitsware » User IP Logged

dfeugey
Guest
xx Re: CD-quality stereo SOUND!
« Reply #34 on: Jun 12th, 2015, 08:35am »

on Jun 11th, 2015, 11:43pm, hitsware wrote:
Your manners and sweet disposition are appreciated, but most times accompanied by an over optimistic view of my abilities .............. smiley

Mine too. I forget something very important: if HQSound lib is used once, then all the software will use it, even without the include. You must relaunch the IDE to come back to 8bit sound. HQSound is not a patch of your code, but a patch of BBC4Win runtime.

So to remove the first line after a first run is no use. You must remove it at first and add it later to hear the (big) difference.
User IP Logged

rtr2
Guest
xx Re: CD-quality stereo SOUND!
« Reply #35 on: Jun 12th, 2015, 09:06am »

on Jun 12th, 2015, 08:35am, dfeugey wrote:
HQSound is not a patch of your code, but a patch of BBC4Win runtime

Well it's certainly a patch of my code, but apart from system DLLs (not a good idea to patch them!) the BB4W runtime is the only thing which can be patched. However it's important to appreciate that it's only the memory image that's being patched, not the EXE file itself.

Quote:
So to remove the first line after a first run is no use. You must remove it at first and add it later to hear the (big) difference.

That is documented in the library:

Code:
      REM If run from the BB4W IDE the patch persists for the entire session 

Of course the expectation is that you will run a program from the IDE only during its development phase; once it's fully tested and working it should be 'compiled' to a standalone EXE. At that point the issue is moot, since the patched memory image is unloaded as soon as the process terminates anyway.

If I had developed HQSOUND purely for use in the IDE there would have been no point in making it a CALLed module; I might just as well have made it an ordinary runnable program. But that's no use for patching a 'compiled' program.

Richard.
User IP Logged

rtr2
Guest
xx Re: CD-quality stereo SOUND!
« Reply #36 on: Jun 12th, 2015, 09:25am »

Here's a simple demonstration of an ADSR envelope, including use of the H (hold) and F (flush) bits in the first parameter of SOUND.

To hear the effect hold down the space bar (substituting for a piano key) and then after a while release it again. Whilst the key is held down the Attack, Decay and Sustain phases of the envelope proceed automatically; in this example the sustain phase simply maintains a constant level. When the key is released the Release phase of the envelope commences:

Code:
      ENVELOPE 1,2,0,0,0,0,0,0,5,-4,0,-1,126,60
      oldspace% = FALSE
      REPEAT
        spacebar% = INKEY(-99)
        IF spacebar% <> oldspace% THEN
          oldspace% = spacebar%
          IF spacebar% THEN
            SOUND &0011, 1, 100, -1
          ELSE
            SOUND &0011, 1, 100, 0
            SOUND &1001, 0, 0, -1
          ENDIF
        ENDIF
        delay% = INKEY(1)
      UNTIL FALSE 

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