Author |
Topic: CD-quality stereo SOUND! (Read 1341 times) |
|
hitsware
Junior Member
member is offline
Gender:
Posts: 70
|
|
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
|
|
Logged
|
|
|
|
rtr2
Guest
|
|
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.
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'.
Richard.
|
|
Logged
|
|
|
|
hitsware
Junior Member
member is offline
Gender:
Posts: 70
|
|
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 ..............
|
« Last Edit: Jun 12th, 2015, 01:05am by hitsware » |
Logged
|
|
|
|
dfeugey
Guest
|
|
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 .............. |
|
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.
|
|
Logged
|
|
|
|
rtr2
Guest
|
|
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.
|
|
Logged
|
|
|
|
rtr2
Guest
|
|
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.
|
|
Logged
|
|
|
|
dfeugey
Guest
|
|
Re: CD-quality stereo SOUND!
« Reply #37 on: Jun 12th, 2015, 10:23am » |
|
Quote:That is documented in the library |
|
We always complain of lack of documentation, but we never read it Anyway, thanks for all the explanations. Very useful library.
|
|
Logged
|
|
|
|
rtr2
Guest
|
|
Re: CD-quality stereo SOUND!
« Reply #39 on: Jun 12th, 2015, 11:54am » |
|
on Jun 12th, 2015, 10:45am, dfeugey wrote:Nota: I have a small noise when I begin to play something. |
|
There's quite a nasty transient when the Windows waveOut subsystem is initialised, which is more noticeable when using HQSOUND. In part that's because the 16-bit samples are signed whereas the original 8-bit samples are unsigned, so the buffer gets initialised to an inappropriate value.
In principle the patching could be made more extensive, so that the buffer initialisation is also modified, but that's a fair amount of work just to reduce the audibility of the transient. Since it happens just once (unless your code contains a SOUND OFF, which is not recommended) a more practical solution is to add an initial delay of a second or so to allow the transient to decay before any 'real' music is output, e.g.:
Code: SOUND 0,0,0,20
SOUND 1,0,0,20
SOUND 2,0,0,20
SOUND 3,0,0,20 Richard.
|
« Last Edit: Jun 12th, 2015, 11:57am by rtr2 » |
Logged
|
|
|
|
hitsware
Junior Member
member is offline
Gender:
Posts: 70
|
|
Re: CD-quality stereo SOUND!
« Reply #40 on: Jun 12th, 2015, 8:48pm » |
|
ENVELOPE to 0 .......... Only took 5 years :)
Re: noise The main noise I hear is during a lone low note with attendant envelope. Like I'm hearing the steps. HQSOUND seemed to help until I turn system gain up enough to match no HQSOUND and the noise is back. Code:
REM CALL @lib$+"HQSOUND"
*TEMPO 133
ENVELOPE 1,0,0,0,0,0,0,0,63,0,0,0,40,0
ENVELOPE 2,0,0,0,0,0,0,0,127,0,0,-2,126,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
REM SOUND 0,1,orgn(x)+48,4
REM SOUND 1,1,orgn(x)+76,4
SOUND (4098-(bass(y)*4096)),2,orgn(x),1:SOUND 4098,2,0,3
REM 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 1,0,0,1, 1,0,0,0
DATA 4,4,3,4, 4,4,3,4
|
|
Logged
|
|
|
|
rtr2
Guest
|
|
Re: CD-quality stereo SOUND!
« Reply #41 on: Jun 13th, 2015, 02:53am » |
|
on Jun 12th, 2015, 8:48pm, hitsware wrote:Like I'm hearing the steps. |
|
You may well be hearing the steps - SOUND has only 16 different levels (0-15) remember, which is quite coarse (they are 2dB steps I think). In fact you will probably hear the steps more clearly when using HQSOUND, since they aren't masked by quantising noise any longer!
I think you might find it helpful to consider the theoretical aspects of the BBC BASIC sound system (both with and without HQSOUND), rather than experimenting and trying to interpret what you hear. The beauty of digital audio is that everything is predictable, if you know the fundamental parameters (sampling rate etc.).
It's the same with all aspects of software really; trial and error is never the right way to do it.
Richard.
|
|
Logged
|
|
|
|
hitsware
Junior Member
member is offline
Gender:
Posts: 70
|
|
Re: CD-quality stereo SOUND!
« Reply #42 on: Jun 19th, 2015, 5:49pm » |
|
Richard, For some reason your last message has disappeared ?
Good Oh ! ...... 2nd HQ works great ;D
How do I set ..
voice 0 left voice 1 right voice 2 & 3 center
Thank You .................
Code:
REM Initialise stereo mix:
M%!0 = &40004000 : REM left 1,0
M%!4 = &00000000 : REM left 3,2
M%!8 = &00000000 : REM right 1,0
M%!12 = &40004000 : REM right 3,2
|
|
Logged
|
|
|
|
rtr2
Guest
|
|
Re: CD-quality stereo SOUND!
« Reply #43 on: Jun 19th, 2015, 7:11pm » |
|
on Jun 19th, 2015, 5:49pm, hitsware wrote:For some reason your last message has disappeared ? |
|
It's still visible to me.
Quote: The REMs in the code you listed tell you. Just set the fields to the required gain values; there are eight 16-bit fields corresponding directly to the four 'left' gains and the four 'right' gains.
Richard.
|
|
Logged
|
|
|
|
hitsware
Junior Member
member is offline
Gender:
Posts: 70
|
|
Re: CD-quality stereo SOUND!
« Reply #44 on: Jun 19th, 2015, 10:03pm » |
|
Greek to me .........
|
|
Logged
|
|
|
|
|