BasicMicroUK - Forums

www.basicmicro.co.uk
It is currently Mon Jul 16, 2018 3:44 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: SoundGin Pbasic code porting over
PostPosted: Sat Dec 15, 2012 7:50 pm 
Offline
Citizen

Joined: Wed Feb 01, 2012 5:57 am
Posts: 11
Although the SoundGin isn't produced any more I have some and got test code on the web. "BabbleBot" IC's are being produced and are supposed to be the same firmware licensed.
I made some minor changes for the BasicNano chip I have running my christmas lights and intend to integrate music into the scheme with it.

Code:
' *          Basic Nano to SoundGin demo program               *
' *          converted from code written by                    *
' *          Vern Graner SSE, Texas Information Services       *
' *          V0.7 (VLG) 4-3-2007                               *
' *          for a Basic Stamp using the pbasic compiler       *

' System Definitions
 ESC    con 27     ' set the escape character
 PRESET con 75     ' preset

' System Variables
  cntI        VAR     Byte   '  counters
  cntB        VAR     Byte   '

' Pin Definitions
  SOUNDGIN    CON 17  ' serial out pin to SoundGin RX pin
   
  MusicalNoteOscA1    CON     88
  MusicalNoteOscA2    CON     89
  MusicalNoteOscA3    CON     90

  OscControlA1        CON     16
  OscControlA2        CON     32
  OscControlA3        CON     48

  OscSine             CON     0
  OscTriangle         CON     1
  OscSaw              CON     2
  OscRamp             CON     3
  OscPulse            CON     4
  OscNoise            CON     5

Shape var byte

preSPACEWARP        CON     0  ' 0 Space Warp
preWABA             CON     1  ' 1 Waba
preRANDOMTHOUGHTS   CON     2  ' 2 Random Thoughts
preGONG             CON     3  ' 3 Gong
prePWANG            CON     4  ' 4 Pwang
preWOW              CON     5  ' 5 Wow
preRANANANA         CON     6  ' 6 Rananana
preTWARTY           CON     7  ' 7 Twarty
preTELLY            CON     8  ' 8 Telly
prePULSATOR         CON     9  ' 9 Pulsator
preBOUNCE           CON     10 '10 Bounce
preTIPTOE           CON     11 '11 Tip Toe
preSPOKES           CON     12 '12 Spokes
preCHOPPER          CON     13 '13 Chopper
prePHAZER           CON     14 '14 Phazer
prePOWERLINES       CON     15 '15 Power Lines
preHEAVYMETAL1      CON     16 '16 Heavy Metal 1
preHEAVYMETAL2      CON     17 '17 Heavy Metal 2
preACMOTOR          CON     18 '18 AC Motor
preYAYA             CON     19 '19 Ya-Ya
preMARCH            CON     20 '20 March
preNOISECHATTER     CON     21 '21 Noise Chatter
preBLIPCHATTER      CON     22 '22 Blip Chatter
preCARNEY           CON     23 '23 Carney
preEARTHQUAKE       CON     24 '24 Earth Quake
preMINDPROBE        CON     25 '25 Mind Probe
preSIREN            CON     26 '26 Siren
preSQUABA           CON     27 '27 Squaba
preSTEAMLOCOMOTIVE  CON     28 '28 Steam Locomotive
preSIMPLEFM         CON     29 '29 Simple Frequency Modulation
preSIMPLEAM         CON     30 '30 Simple Amplitude Modulation
 
MAIN:
 
  gosub SGreset
for shape = 0 to 5
  gosub SGoscControl
  gosub sgPlayScale
next 
  gosub ThreeNoteChord
 
  gosub PlayPresets
 
goto main


SGoscControl:
  SEROUT SOUNDGIN, i9600, [ESC, 4, OscControlA1, 7, Shape]
return

SGPlayScale:

    FOR cntI = 64 TO 75
      SEROUT SOUNDGIN, i9600, [ESC, MusicalNoteOscA1, cntI]
      PAUSE 150
      SEROUT SOUNDGIN, i9600, [ESC,84]
      PAUSE 10
    NEXT

    FOR cntI = 80 TO 91
      SEROUT SOUNDGIN, i9600, [ESC, MusicalNoteOscA1, cntI]
      PAUSE 150
      SEROUT SOUNDGIN, i9600, [ESC,84]
      PAUSE 10
    NEXT

RETURN
   
SGReset:

   SEROUT SOUNDGIN, i9600, [ESC,ESC,ESC,ESC,ESC,ESC,ESC,ESC]
   PAUSE 1000
   RETURN
   
ThreeNoteChord:
   GOSUB SGReset                       ' Reset soundgin
 
   SEROUT Soundgin, i9600, [ESC,88,64] 'start a note on A1
   PAUSE 500

   SEROUT Soundgin, i9600, [ESC,89,68] 'start a note on A2
   PAUSE 500

   SEROUT Soundgin, i9600, [ESC,90,71] 'start a note on A3
   PAUSE 500

   PAUSE 3000

  SEROUT Soundgin, i9600, [ESC,84] 'stop A1
  SEROUT Soundgin, i9600, [ESC,85] 'stop A2
  SEROUT Soundgin, i9600, [ESC,86] 'stop A3
 return
 
PlayPresets:

  GOSUB SGReset       ' Reset soundgin

  FOR cntI = 0 TO 30
    SEROUT SOUNDGIN, i9600, [ESC,PRESET,cntI]
    PAUSE 1000
  NEXT
  PAUSE 1000
  GOSUB SGReset
 return


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group

phpBB SEO