diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json deleted file mode 100644 index e2dfa95..0000000 --- a/.devcontainer/devcontainer.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "customizations": { - "vscode": { - "extensions": [ - "golang.Go", - "github.copilot" - ] - } - }, - "features": { - "ghcr.io/devcontainers/features/sshd:1": { - "version": "latest" - } - }, - "image": "mcr.microsoft.com/devcontainers/go" -} diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 0845eaf..c5456fc 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -11,10 +11,15 @@ jobs: steps: - uses: actions/checkout@v3 + - name: install alsa-utils + run: | + sudo apt-get -y update + sudo apt-get -y install alsa-utils libasound2-dev + - name: Set up Go uses: actions/setup-go@v4 with: - go-version: '1.20' + go-version: '1.24' - name: Build run: make setup build diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..5f5c41c --- /dev/null +++ b/Makefile @@ -0,0 +1,28 @@ +.PHONY: all +all: setup fmt build test + +.PHONY: setup +setup: + go mod download + go mod tidy + +.PHONY: build +build: clean + @echo "==> Building Packages <==" + go build -v ./... + @echo "==> Building cli <==" + go build -o dist/cli ./cmd/impulse/... + +.PHONY: test +test: + @echo "==> running Go tests <==" + go test -race ./... + +.PHONY: fmt +fmt: + go fmt ./... + +.PHONY: clean +clean: + @echo "==> Cleaning dist/ <==" + rm -fr dist/* diff --git a/cmd/impulse/loader.go b/cmd/impulse/loader.go index 72f0715..fa6c33f 100644 --- a/cmd/impulse/loader.go +++ b/cmd/impulse/loader.go @@ -20,4 +20,4 @@ func loadModule(filePath string) (module.Module, error) { return nil, fmt.Errorf("failed to load module: %v", err) } return m, nil -} \ No newline at end of file +} diff --git a/cmd/impulse/main.go b/cmd/impulse/main.go index b5c76b4..a09e005 100644 --- a/cmd/impulse/main.go +++ b/cmd/impulse/main.go @@ -85,4 +85,4 @@ func main() { if err := app.Run(os.Args); err != nil { log.Fatal(err) } -} \ No newline at end of file +} diff --git a/examples/volume-envelope.xm b/examples/volume-envelope.xm new file mode 100644 index 0000000..395ce88 Binary files /dev/null and b/examples/volume-envelope.xm differ diff --git a/internal/player/audioplayer.go b/internal/player/audioplayer.go index cf3d08b..de02fc8 100644 --- a/internal/player/audioplayer.go +++ b/internal/player/audioplayer.go @@ -130,15 +130,15 @@ func (w *WavPlayer) writeWavHeader() { // "fmt " sub-chunk w.writer.Write([]byte("fmt ")) - binary.Write(w.writer, binary.LittleEndian, uint32(16)) // Sub-chunk size - binary.Write(w.writer, binary.LittleEndian, uint16(1)) // Audio format (PCM) - binary.Write(w.writer, binary.LittleEndian, uint16(w.opts.NumChannels)) // Num channels - binary.Write(w.writer, binary.LittleEndian, uint32(w.opts.SampleRate)) // Sample rate + binary.Write(w.writer, binary.LittleEndian, uint32(16)) // Sub-chunk size + binary.Write(w.writer, binary.LittleEndian, uint16(1)) // Audio format (PCM) + binary.Write(w.writer, binary.LittleEndian, uint16(w.opts.NumChannels)) // Num channels + binary.Write(w.writer, binary.LittleEndian, uint32(w.opts.SampleRate)) // Sample rate binary.Write(w.writer, binary.LittleEndian, uint32(w.opts.SampleRate*w.opts.NumChannels*w.opts.BitDepth)) // Byte rate - binary.Write(w.writer, binary.LittleEndian, uint16(w.opts.NumChannels*w.opts.BitDepth)) // Block align - binary.Write(w.writer, binary.LittleEndian, uint16(w.opts.BitDepth*8)) // Bits per sample + binary.Write(w.writer, binary.LittleEndian, uint16(w.opts.NumChannels*w.opts.BitDepth)) // Block align + binary.Write(w.writer, binary.LittleEndian, uint16(w.opts.BitDepth*8)) // Bits per sample // "data" sub-chunk w.writer.Write([]byte("data")) binary.Write(w.writer, binary.LittleEndian, uint32(0)) // Placeholder for data size -} \ No newline at end of file +} diff --git a/internal/player/protracker_ticker.go b/internal/player/protracker_ticker.go index 1f76d71..55d0751 100644 --- a/internal/player/protracker_ticker.go +++ b/internal/player/protracker_ticker.go @@ -2,7 +2,6 @@ package player import "github.com/jesseward/impulse/pkg/module" - var periodTable = [16 * 36]uint16{ 856, 808, 762, 720, 678, 640, 604, 570, 538, 508, 480, 453, 428, 404, 381, 360, 339, 320, 302, 285, 269, 254, 240, 226, 214, 202, 190, 180, 170, 160, 151, 143, 135, 127, 120, 113, 850, 802, 757, 715, 674, 637, 601, 567, 535, 505, 477, 450, 425, 401, 379, 357, 337, 318, 300, 284, 268, 253, 239, 225, 213, 201, 189, 179, 169, 159, 150, 142, 134, 126, 119, 113, @@ -356,4 +355,4 @@ func (t *ProtrackerTicker) RenderChannelTick(p *Player, state *channelState, tic state.samplePos += step } } -} \ No newline at end of file +} diff --git a/pkg/protracker/protracker.go b/pkg/protracker/protracker.go index 2edba17..3266ae1 100644 --- a/pkg/protracker/protracker.go +++ b/pkg/protracker/protracker.go @@ -166,7 +166,6 @@ func (s *Sample) Panning() byte { return 128 // Protracker is mono } - func (s *Sample) LoopEnd() uint32 { return uint32(s.loopStart + s.loopLength) } diff --git a/pkg/xm/xm.go b/pkg/xm/xm.go index b2b591e..856cf42 100644 --- a/pkg/xm/xm.go +++ b/pkg/xm/xm.go @@ -542,7 +542,6 @@ func (s *Sample) Panning() byte { return s.panning } - func (s *Sample) LoopEnd() uint32 { return s.loopStart + s.loopLength } diff --git a/pkg/xm/xm_test.go b/pkg/xm/xm_test.go index 95bafce..a9f4b5d 100644 --- a/pkg/xm/xm_test.go +++ b/pkg/xm/xm_test.go @@ -18,4 +18,4 @@ func TestRead(t *testing.T) { if err != nil { t.Fatalf("Read() failed: %v", err) } -} \ No newline at end of file +}