Shop OBEX P1 Docs P2 Docs Learn Events
Counting cycles on BS2P — Parallax Forums

Counting cycles on BS2P

walkboneswalkbones Posts: 30
edited 2006-09-20 00:59 in BASIC Stamp
Hi,

I'm a beginner so don't laugh. I want to play·the next in a sequence of WAV files from a sampler each time my program passes a certain point. I want to play up to 32 files sequentially·if the·program progresses that far. So, I've got each of the 32 unique serial commands listed with Labels of "counting1" through "counting32".

How can I play the first sample, called·counting1, the first cycle and then increment to the next sample each time the program advances that far?

Buck

Comments

  • ZootZoot Posts: 2,227
    edited 2006-09-19 23:09
    I think the code below is along the lines of what you're trying to do?

    counter         VAR     Byte
    
    counter = 0   'initialize
    
    Main:
    'do a bunch of stuff
    ' more stuff
    ' time for a wav file
    GOSUB Play_Next_Wave
    ' more stuff
    ' more stuff
    'time for another wav
    GOSUB Play_Next_Wave
    
    Done:
    GOTO Done
    
    END
    
    'subroutine
    Play_Next_Wave:
        counter = counter+1
        IF counter > 32 THEN counter = 1
        ON counter-1 GOTO Wav1, Wav2, Wav3, Wav4   'add in labels for all your wav outs
        
         Wav1:
              'your serial code here
         RETURN
         Wav2:
               'your serial code here
         RETURN
               'etc
    
    



    Although a better way to do it would probably be to store your actual serial commands in EE data, and read back the commands themselves, rather than lots of serial commands over and over.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    When the going gets weird, the weird turn pro. -- HST
  • walkboneswalkbones Posts: 30
    edited 2006-09-20 00:59
    Thank you,

    That looks like just what I needed. I'll try it tomorrow.

    Buck
Sign In or Register to comment.