diff --git a/frontend/src/components/Presets/Buttons/DebugButton.vue b/frontend/src/components/Presets/Buttons/DebugButton.vue index b17d9845..5fa90c46 100644 --- a/frontend/src/components/Presets/Buttons/DebugButton.vue +++ b/frontend/src/components/Presets/Buttons/DebugButton.vue @@ -8,7 +8,6 @@ Debug Mix MP3 - Mix WAV diff --git a/internal/encoder/filetype/filetype.go b/internal/encoder/filetype/filetype.go index 49b5fa6e..921dc396 100644 --- a/internal/encoder/filetype/filetype.go +++ b/internal/encoder/filetype/filetype.go @@ -8,7 +8,6 @@ import ( "github.com/faiface/beep" "github.com/gabe565/relax-sounds/internal/encoder" "github.com/gabe565/relax-sounds/internal/encoder/mp3" - "github.com/gabe565/relax-sounds/internal/encoder/wav" ) //go:generate stringer -type FileType -linecomment @@ -16,8 +15,7 @@ import ( type FileType uint8 const ( - Wav FileType = iota // wav - Mp3 // mp3 + Mp3 FileType = iota // mp3 ) var ErrInvalidFileType = errors.New("invalid file type") @@ -39,8 +37,6 @@ func (i *FileType) UnmarshalText(b []byte) error { func (i FileType) ContentType() string { switch i { - case Wav: - return "audio/wav" case Mp3: return "audio/mp3" } @@ -49,8 +45,6 @@ func (i FileType) ContentType() string { func (i FileType) NewEncoder(w io.Writer, format beep.Format) (encoder.Encoder, error) { switch i { - case Wav: - return wav.NewEncoder(w, format) case Mp3: return mp3.NewEncoder(w, format) } diff --git a/internal/encoder/filetype/filetype_string.go b/internal/encoder/filetype/filetype_string.go index 345c1262..f6f6d8dc 100644 --- a/internal/encoder/filetype/filetype_string.go +++ b/internal/encoder/filetype/filetype_string.go @@ -8,13 +8,12 @@ func _() { // An "invalid array index" compiler error signifies that the constant values have changed. // Re-run the stringer command to generate them again. var x [1]struct{} - _ = x[Wav-0] - _ = x[Mp3-1] + _ = x[Mp3-0] } -const _FileType_name = "wavmp3" +const _FileType_name = "mp3" -var _FileType_index = [...]uint8{0, 3, 6} +var _FileType_index = [...]uint8{0, 3} func (i FileType) String() string { if i >= FileType(len(_FileType_index)-1) { diff --git a/internal/encoder/wav/wav.go b/internal/encoder/wav/wav.go deleted file mode 100644 index b1bad7c3..00000000 --- a/internal/encoder/wav/wav.go +++ /dev/null @@ -1,65 +0,0 @@ -package wav - -import ( - "encoding/binary" - "io" - - "github.com/faiface/beep" -) - -type Encoder struct { - w io.Writer - Format beep.Format -} - -type header struct { - RiffMark [4]byte - FileSize int32 - WaveMark [4]byte - FmtMark [4]byte - FormatSize int32 - FormatType int16 - NumChans int16 - SampleRate int32 - ByteRate int32 - BytesPerFrame int16 - BitsPerSample int16 - DataMark [4]byte - DataSize int32 -} - -func (e Encoder) Write(p []byte) (n int, err error) { - return e.w.Write(p) -} - -func (e Encoder) Close() error { - return nil -} - -func NewEncoder(w io.Writer, format beep.Format) (io.WriteCloser, error) { - encoder := Encoder{ - w: w, - Format: format, - } - - h := header{ - RiffMark: [4]byte{'R', 'I', 'F', 'F'}, - FileSize: -1, // finalization - WaveMark: [4]byte{'W', 'A', 'V', 'E'}, - FmtMark: [4]byte{'f', 'm', 't', ' '}, - FormatSize: 16, - FormatType: 1, - NumChans: int16(format.NumChannels), - SampleRate: int32(format.SampleRate), - ByteRate: int32(int(format.SampleRate) * format.NumChannels * format.Precision), - BytesPerFrame: int16(format.NumChannels * format.Precision), - BitsPerSample: int16(format.Precision) * 8, - DataMark: [4]byte{'d', 'a', 't', 'a'}, - DataSize: -1, // finalization - } - if err := binary.Write(w, binary.LittleEndian, &h); err != nil { - return encoder, err - } - - return encoder, nil -}