-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 40604f1
Showing
15 changed files
with
4,686 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
name: Build and Test | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
|
||
jobs: | ||
build: | ||
name: Build and Test - ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
include: | ||
- os: ubuntu-latest | ||
goos: linux | ||
goarch: amd64 | ||
ext: "" | ||
name: melodica-linux-x86_64 | ||
|
||
- os: windows-latest | ||
goos: windows | ||
goarch: amd64 | ||
ext: ".exe" | ||
name: melodica-windows-x86_64.exe | ||
|
||
- os: macos-latest | ||
goos: darwin | ||
goarch: arm64 | ||
ext: "" | ||
name: melodica-darwin-arm64 | ||
build_supported: false | ||
|
||
runs-on: ${{ matrix.os }} | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
# Install audio dependencies for Linux | ||
- name: Install dependencies (Linux) | ||
if: matrix.os == 'ubuntu-latest' | ||
run: | | ||
sudo apt update | ||
sudo apt install -y libasound2-dev | ||
- name: Set up Go | ||
uses: actions/setup-go@v4 | ||
with: | ||
go-version: "1.23.2" | ||
|
||
# Separate build step for non-Windows OS | ||
- name: Build binary (Non-Windows) | ||
if: matrix.os != 'windows-latest' | ||
run: | | ||
mkdir -p dist | ||
GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} go build -o dist/${{ matrix.name }} ./cmd/melodica/main.go | ||
# Separate build step for Windows | ||
- name: Build binary (Windows) | ||
if: matrix.os == 'windows-latest' | ||
run: | | ||
mkdir -p dist | ||
go build -o dist/${{ matrix.name }} ./cmd/melodica/main.go | ||
shell: pwsh | ||
|
||
- name: Run tests | ||
run: go test ./... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
name: Build and Release | ||
|
||
on: | ||
release: | ||
types: [created] | ||
|
||
jobs: | ||
build: | ||
name: Build and Release - ${{ matrix.os }} | ||
permissions: | ||
contents: write | ||
strategy: | ||
matrix: | ||
include: | ||
- os: ubuntu-latest | ||
goos: linux | ||
goarch: amd64 | ||
ext: "" | ||
name: melodica-linux-x86_64 | ||
|
||
- os: windows-latest | ||
goos: windows | ||
goarch: amd64 | ||
ext: ".exe" | ||
name: melodica-windows-x86_64.exe | ||
|
||
- os: macos-latest | ||
goos: darwin | ||
goarch: arm64 | ||
ext: "" | ||
name: melodica-darwin-arm64 | ||
build_supported: false | ||
|
||
runs-on: ${{ matrix.os }} | ||
env: | ||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
GOOS: ${{ matrix.goos }} | ||
GOARCH: ${{ matrix.goarch }} | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
# Install audio dependencies for Linux | ||
- name: Install dependencies (Linux) | ||
if: matrix.os == 'ubuntu-latest' | ||
run: | | ||
sudo apt update | ||
sudo apt install -y libasound2-dev | ||
- name: Set up Go | ||
uses: actions/setup-go@v4 | ||
with: | ||
go-version: "1.23.2" | ||
|
||
# Separate build step for non-Windows OS | ||
- name: Build binary (Non-Windows) | ||
if: matrix.os != 'windows-latest' | ||
run: | | ||
mkdir -p dist | ||
GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} go build -o dist/${{ matrix.name }} ./cmd/melodica/main.go | ||
# Separate build step for Windows | ||
- name: Build binary (Windows) | ||
if: matrix.os == 'windows-latest' | ||
run: | | ||
mkdir -p dist | ||
go build -o dist/${{ matrix.name }} ./cmd/melodica/main.go | ||
shell: pwsh | ||
|
||
# Rename binary to "melodica" (without architecture) | ||
- name: Rename binary | ||
run: | | ||
cd dist | ||
mv "${{ matrix.name }}" "melodica${{ matrix.ext }}" | ||
- name: Copy playlist file | ||
run: | | ||
cp playlist.txt dist/ | ||
shell: bash | ||
|
||
# Create zip archive (Non-Windows) | ||
- name: Create zip archive (Non-Windows) | ||
if: matrix.os != 'windows-latest' | ||
run: | | ||
cd dist | ||
zip "melodica-${{ matrix.os }}.zip" "melodica${{ matrix.ext }}" playlist.txt | ||
shell: bash | ||
|
||
# Create zip archive (Windows) | ||
- name: Create zip archive (Windows) | ||
if: matrix.os == 'windows-latest' | ||
run: | | ||
Compress-Archive -Path dist\melodica.exe, dist\playlist.txt -DestinationPath dist\melodica-windows.zip | ||
shell: pwsh | ||
|
||
- name: Upload zip archive to release | ||
uses: softprops/action-gh-release@v1 | ||
with: | ||
files: | | ||
dist/melodica-${{ matrix.os }}.zip | ||
dist/melodica-windows.zip | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
local.txt | ||
dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# Variables | ||
GOOS ?= $(shell go env GOOS) | ||
GOARCH ?= $(shell go env GOARCH) | ||
BINARY_NAME ?= melodica-$(GOOS)-$(GOARCH) | ||
DIST_DIR ?= dist | ||
CMD_DIR ?= cmd/melodica/main.go | ||
PLAYLIST ?= playlist.txt | ||
|
||
# Default Go version (can be overridden) | ||
GO_VERSION ?= 1.23.2 | ||
|
||
# Set Go build parameters | ||
BUILD_CMD = GOOS=$(GOOS) GOARCH=$(GOARCH) go build -o $(DIST_DIR)/$(BINARY_NAME) $(CMD_DIR) | ||
|
||
.PHONY: all build test clean release run deps | ||
|
||
all: build | ||
|
||
# Install dependencies | ||
deps: | ||
@echo "Installing dependencies..." | ||
ifeq ($(GOOS),linux) | ||
sudo apt update | ||
sudo apt install -y libasound2-dev | ||
endif | ||
|
||
# Build the application | ||
build: deps | ||
@echo "Building application for $(GOOS)/$(GOARCH)..." | ||
@mkdir -p $(DIST_DIR) | ||
$(BUILD_CMD) | ||
|
||
# Run the application with a specified playlist | ||
run: build | ||
@echo "Running application with playlist: $(PLAYLIST)..." | ||
./$(DIST_DIR)/$(BINARY_NAME) $(PLAYLIST) | ||
|
||
# Run tests | ||
test: | ||
@echo "Running tests..." | ||
go test ./... | ||
|
||
# Package the binary and playlist into a zip file for release | ||
release: build | ||
@echo "Creating zip archive for release..." | ||
cp $(PLAYLIST) $(DIST_DIR)/ | ||
cd $(DIST_DIR) && zip "$(BINARY_NAME).zip" "$(BINARY_NAME)" $(PLAYLIST) | ||
|
||
# Clean up build artifacts | ||
clean: | ||
@echo "Cleaning up..." | ||
rm -rf $(DIST_DIR) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
Here's the updated `README.md` with the addition of the `x` key for pause and resume functionality. | ||
|
||
--- | ||
|
||
# Melodica | ||
|
||
Melodica is a console-based audio player built with Go. It supports playback of MP3 files from a playlist and includes basic controls like play, stop, next, previous, volume control, and more. The application is designed to work across multiple operating systems, including Linux, macOS, and Windows. | ||
|
||
## Features | ||
|
||
- **Cross-platform**: Supports Linux, macOS (including Apple Silicon), and Windows. | ||
- **Console Interface**: Simple and lightweight user interface using the terminal. | ||
- **Controls**: | ||
- `Enter`: Play selected track | ||
- `s`: Stop playback | ||
- `n`: Next track | ||
- `p`: Previous track | ||
- `x`: Pause/Resume playback | ||
- `>`: Volume up | ||
- `<`: Volume down | ||
- `Esc`: Quit application | ||
|
||
## Installation | ||
|
||
To install Melodica, ensure you have Go installed (version 1.20 or later). You can install the latest version of Melodica directly from the GitHub repository using the following command: | ||
|
||
```bash | ||
go install github.com/zombocoder/melodica@latest | ||
``` | ||
|
||
This command will download and install Melodica into your `$GOPATH/bin` directory. | ||
|
||
## Usage | ||
|
||
1. **Download a Sample Playlist**: To get started quickly, download a sample `playlist.txt` file from GitHub: | ||
|
||
```bash | ||
curl -o playlist.txt https://raw.githubusercontent.com/zombocoder/melodica/main/playlist.txt | ||
``` | ||
|
||
2. **Run Melodica**: | ||
|
||
```bash | ||
melodica playlist.txt | ||
``` | ||
|
||
3. **Controls**: Use the following key bindings within the application: | ||
- `Enter`: Play the selected track from the playlist | ||
- `s`: Stop the current track | ||
- `n`: Skip to the next track | ||
- `p`: Go back to the previous track | ||
- `x`: Pause or resume playback | ||
- `>`: Increase volume | ||
- `<`: Decrease volume | ||
- `Esc`: Quit the application | ||
|
||
## Makefile Commands | ||
|
||
The `Makefile` provides a convenient way to build and run the application, as well as clean up generated files. | ||
|
||
- **Build**: Compile the application for your OS. | ||
|
||
```bash | ||
make build | ||
``` | ||
|
||
- **Run**: Run the application with a specified playlist file. | ||
|
||
```bash | ||
make run PLAYLIST=playlist.txt | ||
``` | ||
|
||
- **Test**: Run all tests. | ||
|
||
```bash | ||
make test | ||
``` | ||
|
||
- **Clean**: Remove the compiled binary and other generated files. | ||
```bash | ||
make clean | ||
``` | ||
|
||
## Disclaimer | ||
|
||
The audio files used in Melodica are sourced from [Lofi Girl's](https://lofigirl.com/) website and are subject to their [licensing guidelines](https://form.lofigirl.com/CommercialLicense). | ||
|
||
Please ensure compliance with Lofi Girl's licensing terms if you plan to use Melodica in a commercial context. | ||
|
||
--- | ||
|
||
## Development | ||
|
||
To contribute or run the application locally: | ||
|
||
1. Clone the repository: | ||
|
||
```bash | ||
git clone https://github.com/zombocoder/melodica.git | ||
cd melodica | ||
``` | ||
|
||
2. Build the application using `Makefile`: | ||
|
||
```bash | ||
make build | ||
``` | ||
|
||
3. Run the application with your playlist: | ||
```bash | ||
go run cmd/melodica/main.go playlist.txt | ||
``` | ||
|
||
## Building for Other Platforms | ||
|
||
This project is configured with a GitHub Actions workflow that builds and releases artifacts for Linux, macOS (including Apple Silicon), and Windows on each tagged release. | ||
|
||
## License | ||
|
||
This project is licensed under the MIT License. |
Oops, something went wrong.