Jump to content
IGNORED

IntyBASIC SOUND3 Example?


First Spear

Recommended Posts

Did you remember to set the "amplitude mode" (bit 4) in the volume control for the channel in order to let the enveloper generator control that channel's volume?

 

The following two lines make a kind of "UFO woo woo" sound :-

    sound 0, 255, 16 ' Set tone and enable envelope control on this channel.
    sound 3, 400, 14 ' Enable envelope generator in triangle mode.

I think I'll add some PSG constants to the next version of constants.bas in order to handle its envelope generator.

  • Like 3
Link to comment
Share on other sites

What he said, also I would add that intvnut suggested to use volume 48 instead of 16 in order to integrate some really old Intellivision consoles that had a PSG with support for a kind of exponential volume feature.

 

Yep! Its mentioned on page 103 of 119 in the "Your friend, the EXEC" PDF manual.

Link to comment
Share on other sites

Volume envelopes are far more useful than them look at start. I've coded this sample that will be included with future IntyBASIC revisions :)

 

The annex files contain the source code and a updated constants.bas file enhanced by GroovyBee, also to be included.

 

Note: probably it will not sound so nice in PAL Intellivisions as sound frequencies change, only tested in jzintv with NTSC.

    REM
    REM Envelope volume usage
    REM by Oscar Toledo G. http://nanochess.org/
    REM Jan/23/2016
    REM

    INCLUDE "constants.bas"

    PRINT AT 0,"ENVELOPE TEST"

    PRINT AT 21,"1 - PIANO NOTE"
    PRINT AT 41,"2 - SEAWAVES"
    PRINT AT 61,"3 - HELICOPTER"
        PRINT AT 81,"4 - DRUMS ROLLING"
    PRINT AT 101,"5 - SIREN"

main_loop:
    DO
    WAIT
     LOOP UNTIL cont.key <> 12

    IF cont.key = 1 THEN GOSUB effect1
    IF cont.key = 2 THEN GOSUB effect2
    IF cont.key = 3 THEN GOSUB effect3
    IF cont.key = 4 THEN GOSUB effect4
    IF cont.key = 5 THEN GOSUB effect5

    DO
    WAIT
    LOOP UNTIL cont.key = 12

    GOTO main_loop

effect1:    PROCEDURE
    GOSUB reset_sound
    FOR A = 1 TO 10
        IF A=1 THEN #C=477
        IF A=2 THEN #C=379
        IF A=3 THEN #C=319
        IF A=4 THEN #C=477
        IF A=5 THEN #C=379
        IF A=6 THEN #C=319
        IF A=7 THEN #C=451
        IF A=8 THEN #C=358
        IF A=9 THEN #C=301
        IF A=10 THEN #C=239
    SOUND 0,#C,PSG_ENVELOPE_ENABLE
    SOUND 1,(#C+1)/2,PSG_ENVELOPE_ENABLE
    SOUND 2,#C*2,PSG_ENVELOPE_ENABLE
    SOUND 3,6000,PSG_ENVELOPE_SINGLE_SHOT_RAMP_DOWN_AND_OFF    ' Slow decay, single shot \______
    FOR C = 1 TO 30:WAIT:NEXT C
    NEXT A
    RETURN
    END

effect2:    PROCEDURE
    GOSUB reset_sound
    SOUND 1,1,0
    SOUND 2,1,0
    SOUND 4,31,$31
    SOUND 0,2000,PSG_ENVELOPE_ENABLE
    SOUND 3,32000,PSG_ENVELOPE_CYCLE_RAMP_DOWN_SAWTOOTH
    RETURN
    END

effect3:    PROCEDURE
    GOSUB reset_sound
    SOUND 4,8,$30
    SOUND 0,50,PSG_ENVELOPE_ENABLE
    SOUND 3,400,PSG_ENVELOPE_CYCLE_RAMP_UP_TRIANGLE
    RETURN
    END

effect4:    PROCEDURE
    GOSUB reset_sound
    SOUND 4,10,$31
    SOUND 0,2000,PSG_ENVELOPE_ENABLE
    SOUND 3,4000,PSG_ENVELOPE_CYCLE_RAMP_UP_TRIANGLE
    RETURN
    END

effect5:    PROCEDURE
    GOSUB reset_sound
    SOUND 0,100,PSG_ENVELOPE_ENABLE
    SOUND 1,400,PSG_ENVELOPE_ENABLE
    SOUND 3,3600,PSG_ENVELOPE_CYCLE_RAMP_UP_SAWTOOTH
    RETURN
    END

reset_sound:    PROCEDURE
    SOUND 0,1,0
    SOUND 1,1,0
    SOUND 2,1,0
    SOUND 4,,$38
    RETURN
    END

constants.bas

envelope.bas

  • Like 3
Link to comment
Share on other sites

not sure what I am doing wrong. I have the new constans.bas in the lib directory. When I build the envelope.bas using Intybuild command in IntySDK it seems to work but when I run it I get no sound.

 

I get these warnings below. I haven't tried t on real hardware but assume this should work in jzintv.

 

I have the most recent version of IntyBasic and the constants.bas posted above.

Warning: variable 'PSG_ENVELOPE_CYCLE_RAMP_DOWN_SAWTOOTH' read but never assigned
Warning: variable 'PSG_ENVELOPE_CYCLE_RAMP_UP_SAWTOOTH' read but never assigned
Warning: variable 'PSG_ENVELOPE_CYCLE_RAMP_UP_TRIANGLE' read but never assigned
Warning: variable 'PSG_ENVELOPE_ENABLE' read but never assigned
Warning: variable 'PSG_ENVELOPE_SINGLE_SHOT_RAMP_DOWN_AND_OFF' read but never assigned
7 used 8-bit variables of 222 available
1 used 16-bit variables of 47 available
Compilation finished
Assembling...
ERROR SUMMARY - ERRORS DETECTED 0
- WARNINGS 0
Program build completed.
Link to comment
Share on other sites

I get this :-

IntyBASIC compiler v1.2.4 Sep/19/2015
(c) 2014-2015 Oscar Toledo G. http://nanochess.org/

2 used 8-bit variables of 222 available
1 used 16-bit variables of 47 available

Compilation finished

 ERROR SUMMARY - ERRORS DETECTED 0
               -  WARNINGS       0
Make sure you have the same compiler version/date and that there is no constants.bas in the same folder as envelope.bas.
Link to comment
Share on other sites

I get this :-

IntyBASIC compiler v1.2.4 Sep/19/2015
(c) 2014-2015 Oscar Toledo G. http://nanochess.org/

2 used 8-bit variables of 222 available
1 used 16-bit variables of 47 available

Compilation finished

 ERROR SUMMARY - ERRORS DETECTED 0
               -  WARNINGS       0
Make sure you have the same compiler version/date and that there is no constants.bas in the same folder as envelope.bas.

 

damn I'm lazy. I put envelope.bas into the samples directory of the SDK and didn't realize I had an old constants.bas in that directory. and didn't think to look there.

 

works great now.

 

thanks

  • Like 1
Link to comment
Share on other sites

now, does anyone have an example of a cheering crowd. like at the beginning of NFL football or when you hit a homerun in MLB baseball?

Sure! Tinker around with this :-

REM Configure channel mix settings:
REM - A is noise only.
REM - B is tone only.
REM - C is tone only.
    sound 4, 29, PSG_TONE_CHANNELA_DISABLE+PSG_NOISE_CHANNELB_DISABLE+PSG_NOISE_CHANNELC_DISABLE

REM Configure channel A in envelope mode.	
    sound 0, 0, PSG_ENVELOPE_ENABLE
	
REM Configure the envelope generator with ramp up and hold.
    sound 3, 4000, PSG_ENVELOPE_SINGLE_SHOT_RAMP_UP_AND_MAX
	
REM Hold the noise effect for 2 seconds in NTSC.
    for c=1 to 120
        wait
    next c
	
REM Configure the envelope generator to ramp down and off.
    sound 3, 4000, PSG_ENVELOPE_SINGLE_SHOT_RAMP_DOWN_AND_OFF
  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...