Compare commits

..
Author SHA1 Message Date
visionmercer
1d83475666 oi 2026-10-02 11:26:00 +02:00
visionmercer
499fcff6dd remove excessive use of space. 2026-10-02 11:22:56 +02:00
visionmercer
4d5522f1bf Remove useless code 2026-10-01 13:15:43 +02:00
visionmercer
eb50085052 Use whole width if needed. 2026-09-18 11:55:46 +02:00
visionmercer
670a19aae6 Repeat off in ipc. 2026-09-17 12:50:45 +02:00
visionmercer
321b0a3424 configurable
added the ability to use a config file.
2026-09-15 13:16:56 +02:00
visionmercer
662907254a Update readme 2026-09-10 13:59:06 +02:00
2 changed files with 260 additions and 188 deletions

119
cimp.bas
View file

@ -36,16 +36,16 @@ if ipc_status = 0 then
' --- CLIENT MODE ---
dim cmd_msg as string
Select Case command$(1)
Case "--soundbank"
select case command$(1)
case "--soundbank"
cmd_msg="SOUNDBANK:"+_cwd$ +slash+command$(2)
Case "--next"
case "--next"
cmd_msg="NEXT"
Case "--prev"
case "--prev"
cmd_msg="PREV"
Case "-v", "--volume"
case "-v","--volume"
cmd_msg="VOL:"+command$(2)
case "--pause"
@ -62,30 +62,34 @@ if ipc_status = 0 then
cmd_msg="REPEAT"
case "--repeat-1"
cmd_msg="REPEAT1"
case "--repeat-off"
cmd_msg="REPEATOFF"
case "--nyan"
cmd_msg="NYAN"
Case "--add"
For i = 2 To _commandcount
case "--nyan-off"
cmd_msg="NYANOFF"
case "--add"
for i=2 to _commandcount
cmd_msg="ADD:"+_cwd$ +slash+command$(i)
ipc_send_message cmd_msg
Next i
System
next i
system
Case "--playlist"
case "--playlist"
cmd_msg="GET_PLAYLIST"
Case Else
case else
' Default behavior: Resolve target file/playlist and replace active queue
cmd_msg="PLAY:"+_cwd$ +slash+command$(1)
ipc_send_message cmd_msg
If _commandcount > 1 Then
For i = 2 To _commandcount
if _commandcount>1 then
for i=2 to _commandcount
cmd_msg="ADD:"+_cwd$ +slash+command$(i)
ipc_send_message cmd_msg
Next i
System
End If
End Select
next i
system
end if
end select
' Send instruction to the main player instance
ipc_send_message cmd_msg
@ -133,6 +137,8 @@ dim shuffle as integer
dim nooutput as integer
dim timevis as integer
dim nyan as integer
dim server as integer
dim marqueeoffset as integer
dim i as integer
@ -167,6 +173,40 @@ timevis=1
nyan=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
select case command$(i)
case "-v","--volume"
@ -243,14 +283,18 @@ while keyin<>27
repeat=-1
elseif client_cmd="REPEAT1" then
repeat=1
elseif client_cmd="REPEATOFF" then
repeat=0
elseif client_cmd="SHUFFLE" then
keyin=asc("s")
elseif client_cmd="NYAN" then
nyan=not nyan
elseif client_cmd="NYANOFF" then
nyan=0
elseif left$(client_cmd,10)="SOUNDBANK:" then
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.
' 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
tw=termwidth
fixedwidth=uwidth(state)+uwidth(progress)
maxtitlewidth=tw-fixedwidth-2
maxtitlewidth=tw-fixedwidth
currentsongwidth=uwidth(songname)
if currentsongwidth>maxtitlewidth and maxtitlewidth>4 then
@ -625,12 +669,9 @@ end function
function ulen% (txt$)
dim count%,i%,b%
count%=0
for i%=1 to len(txt$)
b%=asc(txt$,i%)
if (b% and &h80)=0 or (b% and &hc0)=&hc0 then
count%=count%+1
end if
if (b% and &h80)=0 or (b% and &hc0)=&hc0 then count%=count%+1
next
ulen%=count%
end function
@ -710,3 +751,35 @@ end function
sub loadsoundbank (filename as string)
_midisoundbank filename
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

View file

@ -129,9 +129,8 @@ When interacting directly with the player interface terminal, use these keys:
## Supported Audio Formats
All formats supported by QB64/QB64PE are supported by cimp, as QB64 handles the
decoding. The following formats are supported by the most recent versions of
both compilers:
All formats supported by QB64PE are supported by cimp, as it handles the
decoding. The following formats are supported by the most recent version:
Audio files:
`mod`, `xm`, `s3m`, `it`, `mid`, `mp3`, `ogg`, and `flac`
@ -143,7 +142,7 @@ Sound banks:
| 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 |
## Notes