cimp/readme.md

153 lines
5.4 KiB
Markdown
Raw Normal View History

2026-06-01 10:10:50 +02:00
# cimp
2026-06-01 10:15:27 +02:00
**c**onsole **i**nterface **m**usic **p**layer
2026-06-24 12:18:21 +02:00
A keyboard-driven music player for the terminal, written in QuickBASIC (QB64).
It plays audio files and M3U playlists directly from the command line, featuring
a minimal two-line display showing playback state and an IPC remote control
interface.
2026-06-01 10:10:50 +02:00
## Features
2026-06-24 12:18:21 +02:00
- Plays individual audio files or M3U playlists.
- Real-time progress bar and time display (elapsed or remaining).
- Volume control and seeking via arrow keys.
- Shuffle and repeat modes.
- **Client/Server IPC Architecture**: Control a running instance of `cimp` from
another terminal window or script.
- Cross-platform: works on Linux, macOS, and Windows.
- Unicode-aware display with support for full-width character width matching.
2026-06-01 10:10:50 +02:00
## Building
1. Clone the repository:
```shell
2026-06-24 12:19:17 +02:00
git clone https://code.oscorp.dk/visionmercer/cimp.git
2026-06-01 10:10:50 +02:00
cd cimp
```
2. Open `cimp.bas` in QB64 and compile, or compile via the terminal:
```shell
qb64 -x cimp.bas
```
## Usage
```shell
cimp [options] <file|playlist> [file2 ...]
```
2026-06-24 12:18:21 +02:00
Pass one or more audio files or `.m3u` playlists. At least one file is required
unless sending a remote control command.
2026-06-01 10:10:50 +02:00
2026-06-24 12:18:21 +02:00
### Global & Server Options
These flags control the primary player instance when launched.
2026-06-01 10:10:50 +02:00
| Flag | Long form | Description |
| -------- | -------------- | ---------------------------------------- |
| `-v <n>` | `--volume <n>` | Set initial volume (0100, default: 100) |
| `-s` | `--shuffle` | Shuffle the playlist on start |
| `-r [1]` | `--repeat [1]` | Repeat all (`-r`) or repeat one (`-r 1`) |
| `-n` | `--nooutput` | Run silently with no display |
2026-06-24 12:18:21 +02:00
### Remote Control (Client Mode) Commands
If `cimp` is already running in a terminal, running it again with any of the
following arguments will send an instruction to the active player instead of
starting a new one:
| Command | Description |
| ------------------------- | ---------------------------------------------------------- |
| `--play` | Resume playback |
| `--pause` | Pause playback |
| `--stop` | Stop playback |
| `--next` | Skip to the next track |
| `--prev` | Skip to the previous track |
| `-v <n>` / `--volume <n>` | Remotely adjust volume (0100) |
| `--shuffle` | Reshuffle the current playlist queue |
| `--repeat` | Set player to repeat all |
| `--repeat-1` | Set player to repeat current track |
| `--add <file>` | Append a new file or playlist to the active queue |
| `--playlist` | Fetch and print the current playback queue from the server |
| `--quit` | Remotely close the running player instance |
2026-06-01 10:10:50 +02:00
### Examples
2026-06-24 12:18:21 +02:00
#### Play a single file normally
2026-06-01 10:10:50 +02:00
```shell
cimp song.mp3
2026-06-24 12:18:21 +02:00
```
### Remote control examples (Run from a separate terminal)
#### Pause the music
```shell
cimp --pause
```
#### Lower the volume to 20%
```shell
cimp --volume 20
```
2026-06-01 10:10:50 +02:00
2026-06-24 12:18:21 +02:00
#### Add another track to the background player's active queue
2026-06-01 10:10:50 +02:00
2026-06-24 12:18:21 +02:00
```shell
cimp --add extra_track.flac
```
#### View the active playlist queue
```shell
cimp --playlist
2026-06-01 10:10:50 +02:00
```
## Keybindings
2026-06-24 12:18:21 +02:00
When interacting directly with the player interface terminal, use these keys:
2026-06-01 10:10:50 +02:00
| Key | Action |
| ------------- | ----------------------------------------- |
| `↑` / `↓` | Volume up / down |
| `←` / `→` | Seek backward / forward 5 seconds |
| `Space` / `c` | Toggle pause / resume |
| `b` | Next track |
| `z` | Previous track (or restart if past 2s) |
| `x` | Restart current track |
| `v` | Stop playback |
| `s` | Reshuffle playlist |
| `t` | Toggle time display (remaining ↔ elapsed) |
| `q` / `Esc` | Quit |
## Supported Audio Formats
2026-06-01 10:15:27 +02:00
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:
2026-06-01 10:10:50 +02:00
`mod`, `xm`, `s3m`, `it`, `mid`, `mp3`, `ogg`, and `flac`
## Files
2026-06-24 12:18:21 +02:00
| File | Description |
| ------------- | --------------------------------------------------------------------------------------- |
| `cimp.bas` | Main player — QB64-PE source handling client/server states and UI |
| `terminkey.h` | C library for cross-platform raw keyboard input, IPC pipes/sockets, and terminal sizing |
2026-06-01 10:10:50 +02:00
## Notes
2026-06-24 12:18:21 +02:00
- **IPC Backend**: On Windows, IPC relies on Named Pipes (`\\.\pipe\cimp_ipc`).
On Linux/macOS, it binds to a local Unix Domain Socket at
`/tmp/cimp_ipc_<uid>.sock`.
2026-06-01 10:10:50 +02:00
- M3U paths can be absolute or relative to the playlist file's directory.
2026-06-01 10:15:27 +02:00
- Volume adjustment is non-linear for a more natural response and better control
at lower ranges.
2026-06-24 12:18:21 +02:00
```
```