-
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.
Start working on client code to prove library works
- Loading branch information
Showing
10 changed files
with
242 additions
and
191 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
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,40 @@ | ||
package mp3 | ||
|
||
import "os" | ||
|
||
func (enc *GlobalConfig) Write(filePath string, pcmData []int16) error { | ||
// Open the output MP3 file for writing. | ||
outputFile, err := os.Create(filePath) | ||
if err != nil { | ||
return err | ||
} | ||
defer outputFile.Close() | ||
var x *int | ||
|
||
// Encoding Loop: Encode PCM data and write to the output file. | ||
var encodedData []byte | ||
samplesPerPass := enc.samplesPerPass() | ||
for len(pcmData) > 0 { | ||
// Determine the number of samples to encode in this pass. | ||
if len(pcmData) < samplesPerPass { | ||
samplesPerPass = len(pcmData) | ||
} | ||
|
||
encodedData = append(encodedData, | ||
encodeBufferInterleaved(enc, pcmData[:samplesPerPass], x)...) | ||
_, err := outputFile.Write(encodedData) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
pcmData = pcmData[samplesPerPass:] | ||
} | ||
|
||
encodedData = flush(enc, x) | ||
_, err = outputFile.Write(encodedData) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
return nil | ||
} |
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
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
Oops, something went wrong.