SOURCE : WPLAYER.IVOS ." AUDIO WAV PLAYER DEMO - Peter Jakacki " ; /* Demonstration of noPC playing wav files from the SD card. At present the system will play 8 or 16 bit mono wav files sampled at 11025Hz or 32000Hz assuming a clean header (Q&D). Assuming that MAIN has been called to setup the task then just type the name of wav file after the PLAY: command. PLAY: beeth9th.wav 01B4.8000: 52 49 46 46 B7 E3 5A 00 57 41 56 45 66 6D 74 20 RIFF7cZ.WAVEfmt 01B4.8010: 12 00 00 00 01 00 01 00 00 7D 00 00 00 7D 00 00 .........}...}.. 01B4.8020: 01 00 08 00 00 00 64 61 74 61 91 E3 5A 00 80 80 ......data.cZ... wav file format 00 4 "RIFF" ID 04 4 FILE SIZE - 8 08 4 "WAVE" RIFF TYPE 0C 4 "fmt" format chunk 10 4 chunk data size = 16+extra format bytes 14 2 0001 compression code 16 2 0001 channels 18 4 7D00 sample rate (32Khz) 1C 4 7D00 average bytes/second 20 2 0001 Block align 22 2 0008 sig bits/sample 24 2 0000 extra format bytes ;64 61 74 61 91 E3 5A 00 26 4 "data" data chunk 2A 4 5AE391 chunk data size */ 400h bytes sndbuf variable sndfile variable sndptr variable sndfsz : /RND DUP >R /MOD SWAP R> 2/ > IF 1+ THEN ; : ?SNDBUF1 4 dacctl BIT? 0= IF sndptr @ sndbuf SDRD DROP BLKSIZ sndptr +! 4 dacctl BSET THEN ; : ?SNDBUF2 8 dacctl BIT? 0= IF sndptr @ sndbuf BLKSIZ + SDRD DROP BLKSIZ sndptr +! 8 dacctl BSET THEN ; : ?SNDLEN 8 dacctl BIT? IF 400h daclen ! ELSE 4 dacctl BIT? IF 200h daclen ! THEN THEN ; : AudioControl: 134h CASE ENDCASE 136h CASE ENDCASE 138h CASE ENDCASE 132h CASE ENDCASE 139h CASE ENDCASE 133h CASE ENDCASE 137h CASE ENDCASE '=' CASE 8 VOL ENDCASE '-' CASE 6 VOL ENDCASE 20h CASE RESET ENDCASE DUP 30h 39h CASES 30h - PLAYR ENDCASE 2DROP ; : AudioControl BEGIN KEYBOARD KEY? ?DUP WHILE AudioControl: REPEAT ; : PLAYLOOP BEGIN AudioControl ?SNDBUF1 ?SNDBUF2 ?SNDLEN 2 dacctl BSET sndptr @ sndfile @ - 400h MIN daclen ! PAUSE sndptr @ sndfile @ - sndfsz @ > UNTIL ; : MAINPLAYLOOP !SP AudioControl sndfile @ DUP sndptr ! IF 0 dacctl C! 0 daclen ! ?SNDBUF1 sndbuf 22h + H@ 16d = IF 10h dacctl BSET THEN 32000d sndbuf 18h + H@ /RND PLAYR sndbuf DUP 2Eh + dacstr D! PLAYLOOP THEN 0 sndfile ! 0 dacctl C! 5 2 -MS ; : PLAYER.TASK !RP !LP 8 VOL 0 sndfile ! BEGIN MAINPLAYLOOP AGAIN ; // Display file name of current selection : |>? dirptr @ .FNAME ; // Stop the current selection : || 0 sndfsz ! ; // Play the current selection : |> fsize @ sndfsz ! fileptr @ sndfile ! ; // Some experimental play controls : >> 20000h sndptr +! ; : << 20000h NEGATE sndptr +! ; : >>| 20h dirptr +! OPENd |> ; // Play next track : |<< 20h NEGATE dirptr +! OPENd |> ; // Play prev track : PLAY: || OPEN: |> ; : PLAYER $" PLAYER.TASK" 4000.2C00h 2 RUN$ ; : MAIN 3 MAMTIM ! // speed-up MOUNT // mount SD ON VIDEO // need video timing OFF DISPLAY // PLAYER // startup player 1 TIMING // min multi-task timing AUTOBAUD // autobaud for console CR QUIT // come back to me ; ' MAIN AUTO ! /* Load summary from IVOS Code 4000.0800-4000.0C73 ( 1139 bytes) Data @4000.3C0C Compiled 136 Lines in 1381ms with 0 Errors */ FINIS