Jump to content

Photo

IntyBASIC SOUND3 Example?


12 replies to this topic

#1 First Spear ONLINE  

First Spear

    Dragonstomper

  • 959 posts

Posted Sat Jan 23, 2016 8:41 AM

I am still struggling with getting SOUND 3 to do anything useful... Can Those With Real Inty Skills ™ put a few lines of example code here in the forum? Just one envolvement change with a tone would get me going I think.

Thanks.

 



#2 GroovyBee OFFLINE  

GroovyBee

    Games Developer

  • 9,675 posts
  • Busy bee!
  • Location:North, England

Posted Sat Jan 23, 2016 11:06 AM

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.



#3 nanochess OFFLINE  

nanochess

    River Patroller

  • 4,502 posts
  • Coding something good
  • Location:Mexico, Mexico

Posted Sat Jan 23, 2016 12:14 PM

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.



#4 GroovyBee OFFLINE  

GroovyBee

    Games Developer

  • 9,675 posts
  • Busy bee!
  • Location:North, England

Posted Sat Jan 23, 2016 12:20 PM

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.



#5 nanochess OFFLINE  

nanochess

    River Patroller

  • 4,502 posts
  • Coding something good
  • Location:Mexico, Mexico

Posted Sat Jan 23, 2016 12:25 PM

Yes, it's in the Manuals section of this site as images http://www.beeslife....brary/index.htm

 

I really would like to get a PDF version :)



#6 nanochess OFFLINE  

nanochess

    River Patroller

  • 4,502 posts
  • Coding something good
  • Location:Mexico, Mexico

Posted Sat Jan 23, 2016 3:44 PM

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

Attached Files



#7 First Spear ONLINE  

First Spear

    Dragonstomper

  • Topic Starter
  • 959 posts

Posted Sat Jan 23, 2016 4:53 PM

Wow.

 

This is so good, you'd thinkthat we scripted this whole thread.    :)

 

Lines 714-725 in the new constants file have diminished my frustration.

 

 

Thanks guys!


Edited by First Spear, Sat Jan 23, 2016 8:25 PM.


#8 fsuinnc OFFLINE  

fsuinnc

    Moonsweeper

  • 417 posts
  • Location:Chapel Hill NC.

Posted Sun Jan 24, 2016 10:14 AM

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.


#9 GroovyBee OFFLINE  

GroovyBee

    Games Developer

  • 9,675 posts
  • Busy bee!
  • Location:North, England

Posted Sun Jan 24, 2016 10:34 AM

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.

#10 fsuinnc OFFLINE  

fsuinnc

    Moonsweeper

  • 417 posts
  • Location:Chapel Hill NC.

Posted Sun Jan 24, 2016 11:00 AM

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



#11 fsuinnc OFFLINE  

fsuinnc

    Moonsweeper

  • 417 posts
  • Location:Chapel Hill NC.

Posted Sun Jan 24, 2016 11:02 AM

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?



#12 GroovyBee OFFLINE  

GroovyBee

    Games Developer

  • 9,675 posts
  • Busy bee!
  • Location:North, England

Posted Sun Jan 24, 2016 11:03 AM

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.


I'm glad it was s simple fix :D
 

works great now.


Good to hear (pun intended :P)
 

thanks


You're welcome!

#13 GroovyBee OFFLINE  

GroovyBee

    Games Developer

  • 9,675 posts
  • Busy bee!
  • Location:North, England

Posted Sun Jan 24, 2016 1:08 PM

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





0 user(s) are browsing this forum

0 members, 0 guests, 0 anonymous users