Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1d83475666 | ||
|
|
499fcff6dd | ||
|
|
4d5522f1bf | ||
|
|
eb50085052 | ||
|
|
670a19aae6 | ||
|
|
321b0a3424 | ||
|
|
662907254a |
2 changed files with 260 additions and 188 deletions
119
cimp.bas
119
cimp.bas
|
|
@ -36,16 +36,16 @@ if ipc_status = 0 then
|
||||||
' --- CLIENT MODE ---
|
' --- CLIENT MODE ---
|
||||||
dim cmd_msg as string
|
dim cmd_msg as string
|
||||||
|
|
||||||
Select Case command$(1)
|
select case command$(1)
|
||||||
Case "--soundbank"
|
case "--soundbank"
|
||||||
cmd_msg="SOUNDBANK:"+_cwd$ +slash+command$(2)
|
cmd_msg="SOUNDBANK:"+_cwd$ +slash+command$(2)
|
||||||
Case "--next"
|
case "--next"
|
||||||
cmd_msg="NEXT"
|
cmd_msg="NEXT"
|
||||||
|
|
||||||
Case "--prev"
|
case "--prev"
|
||||||
cmd_msg="PREV"
|
cmd_msg="PREV"
|
||||||
|
|
||||||
Case "-v", "--volume"
|
case "-v","--volume"
|
||||||
cmd_msg="VOL:"+command$(2)
|
cmd_msg="VOL:"+command$(2)
|
||||||
|
|
||||||
case "--pause"
|
case "--pause"
|
||||||
|
|
@ -62,30 +62,34 @@ if ipc_status = 0 then
|
||||||
cmd_msg="REPEAT"
|
cmd_msg="REPEAT"
|
||||||
case "--repeat-1"
|
case "--repeat-1"
|
||||||
cmd_msg="REPEAT1"
|
cmd_msg="REPEAT1"
|
||||||
|
case "--repeat-off"
|
||||||
|
cmd_msg="REPEATOFF"
|
||||||
case "--nyan"
|
case "--nyan"
|
||||||
cmd_msg="NYAN"
|
cmd_msg="NYAN"
|
||||||
Case "--add"
|
case "--nyan-off"
|
||||||
For i = 2 To _commandcount
|
cmd_msg="NYANOFF"
|
||||||
|
case "--add"
|
||||||
|
for i=2 to _commandcount
|
||||||
cmd_msg="ADD:"+_cwd$ +slash+command$(i)
|
cmd_msg="ADD:"+_cwd$ +slash+command$(i)
|
||||||
ipc_send_message cmd_msg
|
ipc_send_message cmd_msg
|
||||||
Next i
|
next i
|
||||||
System
|
system
|
||||||
|
|
||||||
Case "--playlist"
|
case "--playlist"
|
||||||
cmd_msg="GET_PLAYLIST"
|
cmd_msg="GET_PLAYLIST"
|
||||||
|
|
||||||
Case Else
|
case else
|
||||||
' Default behavior: Resolve target file/playlist and replace active queue
|
' Default behavior: Resolve target file/playlist and replace active queue
|
||||||
cmd_msg="PLAY:"+_cwd$ +slash+command$(1)
|
cmd_msg="PLAY:"+_cwd$ +slash+command$(1)
|
||||||
ipc_send_message cmd_msg
|
ipc_send_message cmd_msg
|
||||||
If _commandcount > 1 Then
|
if _commandcount>1 then
|
||||||
For i = 2 To _commandcount
|
for i=2 to _commandcount
|
||||||
cmd_msg="ADD:"+_cwd$ +slash+command$(i)
|
cmd_msg="ADD:"+_cwd$ +slash+command$(i)
|
||||||
ipc_send_message cmd_msg
|
ipc_send_message cmd_msg
|
||||||
Next i
|
next i
|
||||||
System
|
system
|
||||||
End If
|
end if
|
||||||
End Select
|
end select
|
||||||
|
|
||||||
' Send instruction to the main player instance
|
' Send instruction to the main player instance
|
||||||
ipc_send_message cmd_msg
|
ipc_send_message cmd_msg
|
||||||
|
|
@ -133,6 +137,8 @@ dim shuffle as integer
|
||||||
dim nooutput as integer
|
dim nooutput as integer
|
||||||
dim timevis as integer
|
dim timevis as integer
|
||||||
dim nyan as integer
|
dim nyan as integer
|
||||||
|
dim server as integer
|
||||||
|
|
||||||
dim marqueeoffset as integer
|
dim marqueeoffset as integer
|
||||||
dim i as integer
|
dim i as integer
|
||||||
|
|
||||||
|
|
@ -167,6 +173,40 @@ timevis=1
|
||||||
nyan=0
|
nyan=0
|
||||||
marqueeoffset=0
|
marqueeoffset=0
|
||||||
|
|
||||||
|
|
||||||
|
dim config as string
|
||||||
|
config=GetConfig("cimp.conf")
|
||||||
|
if _fileexists(config) then
|
||||||
|
dim li as string
|
||||||
|
dim fh as integer
|
||||||
|
fh=freefile
|
||||||
|
open config for input as fh
|
||||||
|
while not eof(fh)
|
||||||
|
line input #fh,li
|
||||||
|
if left$(li,1)="#" then _continue
|
||||||
|
select case _trim$(left$(li,instr(li,"=")-1))
|
||||||
|
case "volume"
|
||||||
|
volume=val(_trim$(mid$(li,instr(li,"=")+1)))/100
|
||||||
|
case "shuffle"
|
||||||
|
if _trim$(mid$(li,instr(li,"=")+1))="true" then shuffle=-1 else shuffle=0
|
||||||
|
case "repeat"
|
||||||
|
if _trim$(mid$(li,instr(li,"=")+1))="true" then repeat=-1 else repeat=0
|
||||||
|
if _trim$(mid$(li,instr(li,"=")+1))="1" then repeat=1
|
||||||
|
case "server"
|
||||||
|
if _trim$(mid$(li,instr(li,"=")+1))="true" then server=-1 else server=0
|
||||||
|
case "nyan"
|
||||||
|
if _trim$(mid$(li,instr(li,"=")+1))="true" then nyan=-1 else nyan=0
|
||||||
|
case "nooutput"
|
||||||
|
if _trim$(mid$(li,instr(li,"=")+1))="true" then nooutput=-1 else nooutput=0
|
||||||
|
case ""
|
||||||
|
case else
|
||||||
|
print "Config not understood:"
|
||||||
|
print li
|
||||||
|
end select
|
||||||
|
wend
|
||||||
|
close fh
|
||||||
|
end if
|
||||||
|
|
||||||
for i=1 to _commandcount
|
for i=1 to _commandcount
|
||||||
select case command$(i)
|
select case command$(i)
|
||||||
case "-v","--volume"
|
case "-v","--volume"
|
||||||
|
|
@ -243,14 +283,18 @@ while keyin<>27
|
||||||
repeat=-1
|
repeat=-1
|
||||||
elseif client_cmd="REPEAT1" then
|
elseif client_cmd="REPEAT1" then
|
||||||
repeat=1
|
repeat=1
|
||||||
|
elseif client_cmd="REPEATOFF" then
|
||||||
|
repeat=0
|
||||||
elseif client_cmd="SHUFFLE" then
|
elseif client_cmd="SHUFFLE" then
|
||||||
keyin=asc("s")
|
keyin=asc("s")
|
||||||
elseif client_cmd="NYAN" then
|
elseif client_cmd="NYAN" then
|
||||||
nyan=not nyan
|
nyan=not nyan
|
||||||
|
elseif client_cmd="NYANOFF" then
|
||||||
|
nyan=0
|
||||||
elseif left$(client_cmd,10)="SOUNDBANK:" then
|
elseif left$(client_cmd,10)="SOUNDBANK:" then
|
||||||
if client_cmd="default" then loadsoundbank "" else loadsoundbank mid$(client_cmd,11)
|
if client_cmd="default" then loadsoundbank "" else loadsoundbank mid$(client_cmd,11)
|
||||||
|
|
||||||
if _SNDPLAYING(musichandle) then
|
if _sndplaying(musichandle) then
|
||||||
|
|
||||||
' a hack to make qb64pe load the midi file that is already loaded.
|
' a hack to make qb64pe load the midi file that is already loaded.
|
||||||
' qb64 can't open the same file again with a new sound bank for some reason
|
' qb64 can't open the same file again with a new sound bank for some reason
|
||||||
|
|
@ -416,7 +460,7 @@ while keyin<>27
|
||||||
if nooutput=0 then
|
if nooutput=0 then
|
||||||
tw=termwidth
|
tw=termwidth
|
||||||
fixedwidth=uwidth(state)+uwidth(progress)
|
fixedwidth=uwidth(state)+uwidth(progress)
|
||||||
maxtitlewidth=tw-fixedwidth-2
|
maxtitlewidth=tw-fixedwidth
|
||||||
currentsongwidth=uwidth(songname)
|
currentsongwidth=uwidth(songname)
|
||||||
|
|
||||||
if currentsongwidth>maxtitlewidth and maxtitlewidth>4 then
|
if currentsongwidth>maxtitlewidth and maxtitlewidth>4 then
|
||||||
|
|
@ -625,12 +669,9 @@ end function
|
||||||
|
|
||||||
function ulen% (txt$)
|
function ulen% (txt$)
|
||||||
dim count%,i%,b%
|
dim count%,i%,b%
|
||||||
count%=0
|
|
||||||
for i%=1 to len(txt$)
|
for i%=1 to len(txt$)
|
||||||
b%=asc(txt$,i%)
|
b%=asc(txt$,i%)
|
||||||
if (b% and &h80)=0 or (b% and &hc0)=&hc0 then
|
if (b% and &h80)=0 or (b% and &hc0)=&hc0 then count%=count%+1
|
||||||
count%=count%+1
|
|
||||||
end if
|
|
||||||
next
|
next
|
||||||
ulen%=count%
|
ulen%=count%
|
||||||
end function
|
end function
|
||||||
|
|
@ -710,3 +751,35 @@ end function
|
||||||
sub loadsoundbank (filename as string)
|
sub loadsoundbank (filename as string)
|
||||||
_midisoundbank filename
|
_midisoundbank filename
|
||||||
end sub
|
end sub
|
||||||
|
|
||||||
|
|
||||||
|
function GetConfig$ (FileName as string)
|
||||||
|
select case left$(_os$,instr(_os$,"]"))
|
||||||
|
case "[WINDOWS]"
|
||||||
|
dim appdata as string
|
||||||
|
appdata=environ$("APPDATA")
|
||||||
|
if appdata="" then appdata=environ$("USERPROFILE")+"\AppData\Roaming"
|
||||||
|
if right$(appdata,1)<>"\" then appdata=appdata+"\"
|
||||||
|
GetConfig=appdata+FileName
|
||||||
|
|
||||||
|
case "[MACOSX]"
|
||||||
|
dim homemac as string
|
||||||
|
homemac=environ$("HOME")
|
||||||
|
if homemac="" then homemac="/tmp"
|
||||||
|
if right$(homemac,1)="/" then homemac=left$(homemac,len(homemac)-1)
|
||||||
|
GetConfig=homemac+"/Library/Application Support/"+FileName
|
||||||
|
|
||||||
|
case else ' Linux and other Unix-like systems
|
||||||
|
dim xdg as string,baseDir as string,homelinux as string
|
||||||
|
xdg=environ$("XDG_CONFIG_HOME")
|
||||||
|
if xdg<>"" then
|
||||||
|
baseDir=xdg
|
||||||
|
else
|
||||||
|
homelinux=environ$("HOME")
|
||||||
|
if homelinux="" then homelinux="/tmp"
|
||||||
|
baseDir=homelinux+"/.config"
|
||||||
|
end if
|
||||||
|
if right$(baseDir,1)="/" then baseDir=left$(baseDir,len(baseDir)-1)
|
||||||
|
GetConfig=baseDir+"/"+FileName
|
||||||
|
end select
|
||||||
|
end function
|
||||||
|
|
|
||||||
|
|
@ -129,9 +129,8 @@ When interacting directly with the player interface terminal, use these keys:
|
||||||
|
|
||||||
## Supported Audio Formats
|
## Supported Audio Formats
|
||||||
|
|
||||||
All formats supported by QB64/QB64PE are supported by cimp, as QB64 handles the
|
All formats supported by QB64PE are supported by cimp, as it handles the
|
||||||
decoding. The following formats are supported by the most recent versions of
|
decoding. The following formats are supported by the most recent version:
|
||||||
both compilers:
|
|
||||||
|
|
||||||
Audio files:
|
Audio files:
|
||||||
`mod`, `xm`, `s3m`, `it`, `mid`, `mp3`, `ogg`, and `flac`
|
`mod`, `xm`, `s3m`, `it`, `mid`, `mp3`, `ogg`, and `flac`
|
||||||
|
|
@ -143,7 +142,7 @@ Sound banks:
|
||||||
|
|
||||||
| File | Description |
|
| File | Description |
|
||||||
| ------------- | --------------------------------------------------------------------------------------- |
|
| ------------- | --------------------------------------------------------------------------------------- |
|
||||||
| `cimp.bas` | Main player — QB64-PE source handling client/server states and UI |
|
| `cimp.bas` | Main player - QB64 source handling client/server states and UI |
|
||||||
| `terminkey.h` | C library for cross-platform raw keyboard input, IPC pipes/sockets, and terminal sizing |
|
| `terminkey.h` | C library for cross-platform raw keyboard input, IPC pipes/sockets, and terminal sizing |
|
||||||
|
|
||||||
## Notes
|
## Notes
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue