diff --git a/test/mpg123.tal b/test/mpg123.tal new file mode 100644 index 0000000..03073de --- /dev/null +++ b/test/mpg123.tal @@ -0,0 +1,116 @@ +( mpg123.tal ) +( ) +( runs mpg123 in a pipe, using -R to enable remote mode ) +( ) +( ) +( basic protocol: ) +( ) +( < @R ... ; startup banner ) +( > L path/to/track.mp3 ; starts playing ) +( < @I ... ; ID3 metadata ) +( < @P ... ; playing state ) +( < @S ... ; sound info ) +( < @F ... ; frame/position info ) +( ) +( example session: ) +( ) +( < @R MPG123 (ThOr) v10 ; startup banner ) +( > L spectra.mp3 ; load command ) +( > @I { ; start id3 ) +( > @I ID3v2.title:Spectra ; song title ) +( > @I ID3v2.artist:Chipzel ; artist name ) +( > @I ID3v2.album:Spectra ; album title ) +( > @I ID3v2.year:2013 ; song year ) +( > @I ID3v2.comment:Visit https://chipzelmusic.bandcamp.com ; comment ) +( > @I ... ; other info possible ) +( > @I } ; end id3 ) +( > @P 2 ; song playing ) +( > @S 1.0 3 44100 Joint-Stereo 2 1044 2 0 0 0 320 0 1 ; sound info ) +( > @F 0 9052 0.00 236.46 ; first frame output ) +( > @F ... ; lots of frames of output ) +( > @F 9051 1 236.43 0.03 ; last frame output ) +( > @P 3 ; song ended ) +( > @P 0 ; stopped ) +( ) +( @S _ _ _ _ _ _ ) +( ) +( other commands: ) +( ) +( > LP ; load paused, without playing ) +( ... ) +( < @P 1 ; paused ) +( ) +( > pause ; pause playback ) +( < @P 1 ; paused ) +( > pause ; unpause playback ) +( < @P 1 ; playing ) +( ) +( > stop ; stop playback ) +( < @P 0 ; stopped ) +( ) +( > V 10 ; set volume to 10% ) +( < @V 10.000000% ; current volume ) +( > V 100 ; set volume to 100% ) +( < @V 100.000000% ; current volume ) + +|10 @Console [ + &vector $2 &stdin $1 &pad1 $4 &type $1 + &stdout $1 &stderr $1 &proc-put $1 &pad2 $1 ¶m $2 &opts $1 &host-put $1 +] + +|0000 + +|0100 ( -> BRK ) + ;on-console .Console/vector DEO2 ( ; set up console vector callback ) + #31 .Console/opts DEO ( ; child 1: write child.in, read child.out ) + ;mpg123-cmd .Console/param DEO2 ( ; set up `ispell -a` to run ) + #01 .Console/host-put DEO BRK ( ; run the command now and return ) + +@on-console ( -> BRK ) + .Console/type DEI #01 EQU ?on-stdin + .Console/type DEI #21 EQU ?on-mpg123 + BRK + +@reset ( buf* addr* -> ) + OVR2 #0000 SWP2 STA2 ( ; buf<-0000 ) + STA2 JMP2r ( ; addr<-buf ) + +@save ( c^ addr* -> ) + STH2k LDA2 STH2k ( c^ pos* [addr* pos*] ) + STA INC2r #00 STH2kr STA ( [addr* pos+1*] ; pos<-c, pos+1<-00 ) + STH2r STH2r STA2 JMP2r ( ; addr<-pos+1 ) + +( exec should have type [->] ) +@save-or-exec ( exec* addr* -> BRK ) + ,&addr STR2 ,&exec STR2 + .Console/stdin DEI #0a EQU LIT2 [ &exec $2 ] JCN2 + .Console/stdin DEI LIT2 [ &addr $2 ] !save + +@on-stdin ( -> BRK ) + ;exec-stdin ;input/pos save-or-exec BRK + +@exec-stdin ( -> ) + ;input ;input/pos !reset + +@on-mpg123 ( -> BRK ) + ;exec-mpg123 ;buffer/pos save-or-exec BRK + +@exec-mpg123 ( -> ) + JMP2r + +@print ( c^ -> ) + .Console/stdout DEO JMP2r ( ; print character to stdout ) + +@println ( c^ -> ) + print #0a .Console/stdout DEO JMP2r ( ; print character and newline to stdout ) + +@input [ $80 &pos $2 ] +@buffer [ $80 &pos $2 ] + +@mpg123-cmd "mpg123 20 "-R 00 ( ; "mpg123 -R" ) + +@frames-past $2 +@frames-togo $2 + +@time-past $9 +@time-togo $9