read out carolling christmas bells
| Author | Message | ||||
| phil99 Guru Joined: 11/02/2018 Location: AustraliaPosts: 3378 |
Here is another player program. I noticed the PLAY SOUND command takes time to get processed, causing the tempo to slow a few mS. This fixes that and also has the PORT output to drive the solenoids. It also has provision to increase / decrease the solenoid pulse time to suit your new solenoids. The Port is GP0 to GP11 so sound can be on GP12 and GP13. ' "Glockenspiel player 02.bas" Dim integer note, BellNote, bells, FZ, track Dim float BellTime, Bell.prev, t, PulseChange = 0 'Add to, or subtract from pulse duration (mS) '*******Add your tone sequence here.************* Dim integer tone(11)=(2695,2401,2139,2019,1906,1799,1602,1513,1428,1348,1200,1070) For n=0 To 11 SetPin MM.Info(pinno "GP"+Str$(n)),DOUT Next '*******Add your recorded file name here.************* Open "music.dat" For Input As #1 Print : Print " Track 0 - Bell Test" Timer = 0 Do Input #1, BellTime, BellNote 'get the data If BellTime = 0 Then BellTime = 35' + PulseChange '0 not valid so assume a solenoid pulse If BellTime < 100 Then Inc BellTime, PulseChange 'adjust solenoid pulse for different solenoid If BellTime >= 100 + PulseChange Then Inc BellTime, -PulseChange 'compensate for above to maintain tempo t=Timer If Not bellnote Then Port(gp0,12) = Bells If bellnote Then Port(gp0,12) = 0 If Not BellNote Then Play Stop Print BellTime, BellNote, Bin$(Port(gp0,12),12),, bells=bellnote FZ=0 If BellNote Then For note=0 To 11 If (BellNote>>note) And 1 Then Inc FZ Play SOUND FZ,B,S,tone(note) Print tone(note);"Hz", EndIf Next EndIf If BellTime > 3000 Then Inc track Pause 1000 Play stop Print : Print " Track"; track; " ========== Track"; track EndIf Do : Loop Until Timer-t >= BellTime Loop Until Eof(#1) Port(gp0,12) = 0 'ensure solenoids are off Print : Print "---------- Ende -----------" End Footnote added 2025-11-21 07:54 by phil99 A tester for the program above. 'Test PORT output of glockenspiel program using a second Pico. 'connect GP0 to GP11 plus Gnd. to same pins on other Pico For n=0 To 11 SetPin MM.Info(pinno "GP"+Str$(n)),Din'OUT Next Do Print Bin$(Port(GP0,12),12),Port(GP0,12), t=Timer:Do :Loop Until Port(GP0,12) : Print Cint(Timer-t) Print Bin$(Port(GP0,12),12),Port(GP0,12), t=Timer:Do While Port(GP0,12):Loop : Print Cint(Timer-t) Loop End Footnote added 2025-11-24 17:40 by phil99 Hi Frank, Just in case you get tired of the tracks always playing in the same sequence this program plays all the tracks in a random sequence, except for Track 0 (the Bell Test track) which is always first. Random Player.zip The Zip contains the player program and 23 track .DAT files. Copy them all to A: before running the program. |
||||