-
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.
Add tools for audio conversion and cleanup some binaries
- Loading branch information
1 parent
9c85ac1
commit 8183689
Showing
25 changed files
with
185 additions
and
11 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 |
---|---|---|
@@ -1,6 +1,9 @@ | ||
audio/pcm/*.wav | ||
audio/pcm/*.pcm | ||
build/* | ||
gfx/nemesis/*.smd | ||
gfx/segard/*.smd | ||
rom/* | ||
smps/* | ||
z80/*.bin | ||
z80/pcm_driver/*.bin | ||
|
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
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,10 @@ | ||
module tools | ||
|
||
go 1.22.4 | ||
|
||
require ( | ||
github.com/go-audio/audio v1.0.0 | ||
github.com/go-audio/wav v1.1.0 | ||
) | ||
|
||
require github.com/go-audio/riff v1.0.0 // indirect |
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,6 @@ | ||
github.com/go-audio/audio v1.0.0 h1:zS9vebldgbQqktK4H0lUqWrG8P0NxCJVqcj7ZpNnwd4= | ||
github.com/go-audio/audio v1.0.0/go.mod h1:6uAu0+H2lHkwdGsAY+j2wHPNPpPoeg5AaEFh9FlA+Zs= | ||
github.com/go-audio/riff v1.0.0 h1:d8iCGbDvox9BfLagY94fBynxSPHO80LmZCaOsmKxokA= | ||
github.com/go-audio/riff v1.0.0/go.mod h1:l3cQwc85y79NQFCRB7TiPoNiaijp6q8Z0Uv38rVG498= | ||
github.com/go-audio/wav v1.1.0 h1:jQgLtbqBzY7G+BM8fXF7AHUk1uHUviWS4X39d5rsL2g= | ||
github.com/go-audio/wav v1.1.0/go.mod h1:mpe9qfwbScEbkd8uybLuIpTgHyrISw/OTuvjUW2iGtE= |
Binary file not shown.
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,4 @@ | ||
00000000 0EC0 0EA0 0E80 0E60 0E40+ pal_9F6C: dc.w $EC0, $EA0, $E80, $E60, $E40, $E20, $E00, $C00, $A00 | ||
00000012 ; DATA XREF: draw_segalogo+DC o | ||
00000012 0800 0600 0800 0A00 0C00+ dc.w $800, $600, $800, $A00, $C00, $E00, $E20, $E40, $E60 | ||
00000024 0E80 0EA0 dc.w $E80, $EA0 |
Binary file not shown.
Binary file not shown.
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,66 @@ | ||
package main | ||
|
||
import ( | ||
"encoding/binary" | ||
"fmt" | ||
"io" | ||
"log" | ||
"os" | ||
"strconv" | ||
|
||
"github.com/go-audio/audio" | ||
"github.com/go-audio/wav" | ||
) | ||
|
||
func main() { | ||
pcm_src := os.Args[1] | ||
wav_dest := os.Args[2] | ||
freq, _ := strconv.ParseInt(os.Args[3], 10, 0) | ||
|
||
in, err := os.Open(pcm_src) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
|
||
out, err := os.Create(wav_dest) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
defer out.Close() | ||
|
||
fmt.Print(int(freq)) | ||
|
||
e := wav.NewEncoder(out, int(freq), 8, 1, 1) | ||
|
||
audioBuf, err := newAudioIntBuffer(in, int(freq)) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
|
||
if err := e.Write(audioBuf); err != nil { | ||
log.Fatal(err) | ||
} | ||
if err := e.Close(); err != nil { | ||
log.Fatal(err) | ||
} | ||
} | ||
|
||
func newAudioIntBuffer(r io.Reader, freq int) (*audio.IntBuffer, error) { | ||
buf := audio.IntBuffer{ | ||
Format: &audio.Format{ | ||
NumChannels: 1, | ||
SampleRate: int(freq), | ||
}, | ||
} | ||
for { | ||
var sample int8 | ||
err := binary.Read(r, binary.LittleEndian, &sample) | ||
switch { | ||
case err == io.EOF: | ||
return &buf, nil | ||
case err != nil: | ||
return nil, err | ||
} | ||
buf.Data = append(buf.Data, int(sample)) | ||
} | ||
} |
Binary file not shown.
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,72 @@ | ||
package main | ||
|
||
import ( | ||
"bufio" | ||
"log" | ||
"os" | ||
"strconv" | ||
|
||
"github.com/go-audio/audio" | ||
"github.com/go-audio/wav" | ||
) | ||
|
||
func main() { | ||
wav_src := os.Args[1] | ||
pcm_dest := os.Args[2] | ||
freq, _ := strconv.ParseInt(os.Args[3], 10, 0) | ||
|
||
in, err := os.Open(wav_src) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
|
||
out, err := os.Create(pcm_dest) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
defer out.Close() | ||
|
||
e := wav.NewDecoder(in) | ||
|
||
bfo := bufio.NewWriter(out) | ||
buf := &audio.IntBuffer{ | ||
Format: &audio.Format{ | ||
NumChannels: 1, | ||
SampleRate: int(freq), | ||
}, | ||
Data: make([]int, 2048), | ||
SourceBitDepth: 8, | ||
} | ||
chunk := make([]byte, 2048) | ||
|
||
err = e.FwdToPCM() | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
|
||
n, err := e.PCMBuffer(buf) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
for n > 0 { | ||
k := 0 | ||
p := 0 | ||
for i := 0; i < n; i++ { | ||
chunk[k] = byte(buf.Data[p]) | ||
k++ | ||
p++ | ||
} | ||
|
||
_, err = bfo.Write(chunk[0:k]) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
|
||
n, err = e.PCMBuffer(buf) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
} | ||
bfo.Flush() | ||
|
||
} |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.