mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 02:38:53 +01:00
audio/mp3: Refactoring: Add frame.numberOfChannels
This commit is contained in:
parent
76320010f4
commit
ae85ec991c
@ -29,13 +29,16 @@ var (
|
||||
writer io.Writer
|
||||
)
|
||||
|
||||
func (f *frame) numberOfChannels() int {
|
||||
if f.header.mode == mpeg1ModeSingleChannel {
|
||||
return 1
|
||||
}
|
||||
return 2
|
||||
}
|
||||
|
||||
func (f *frame) decodeL3() error {
|
||||
out := make([]uint32, 576)
|
||||
// Number of channels(1 for mono and 2 for stereo)
|
||||
nch := 2
|
||||
if f.header.mode == mpeg1ModeSingleChannel {
|
||||
nch = 1
|
||||
}
|
||||
nch := f.numberOfChannels()
|
||||
for gr := 0; gr < 2; gr++ {
|
||||
for ch := 0; ch < nch; ch++ {
|
||||
f.l3Requantize(gr, ch)
|
||||
@ -59,10 +62,7 @@ func (f *frame) decodeL3() error {
|
||||
}
|
||||
|
||||
func (f *frame) audioWriteRaw(samples []uint32) error {
|
||||
nch := 2
|
||||
if f.header.mode == mpeg1ModeSingleChannel {
|
||||
nch = 1
|
||||
}
|
||||
nch := f.numberOfChannels()
|
||||
s := make([]uint8, len(samples)*2*nch)
|
||||
for i, v := range samples {
|
||||
if nch == 1 {
|
||||
@ -121,7 +121,6 @@ func getFilepos() int {
|
||||
var eof = errors.New("mp3: expected EOF")
|
||||
|
||||
func decode(r io.Reader, w io.Writer) error {
|
||||
// TODO: Decoder should know number of channels
|
||||
reader = r
|
||||
writer = w
|
||||
for {
|
||||
|
@ -556,11 +556,7 @@ func (f *frame) l3SubbandSynthesis(gr int, ch int, out []uint32) {
|
||||
u_vec := make([]float32, 512)
|
||||
s_vec := make([]float32, 32)
|
||||
|
||||
/* Number of channels(1 for mono and 2 for stereo) */
|
||||
nch := 2
|
||||
if f.header.mode == mpeg1ModeSingleChannel {
|
||||
nch = 1
|
||||
}
|
||||
nch := f.numberOfChannels()
|
||||
/* Setup the n_win windowing vector and the v_vec intermediate vector */
|
||||
for ss := 0; ss < 18; ss++ { /* Loop through 18 samples in 32 subbands */
|
||||
for i := 1023; i > 63; i-- { /* Shift up the V vector */
|
||||
|
@ -27,12 +27,7 @@ var mpeg1_scalefac_sizes = [16][2]int{
|
||||
}
|
||||
|
||||
func (f *frame) readMainL3() error {
|
||||
/* Number of channels(1 for mono and 2 for stereo) */
|
||||
nch := 2
|
||||
if f.header.mode == mpeg1ModeSingleChannel {
|
||||
nch = 1
|
||||
}
|
||||
|
||||
nch := f.numberOfChannels()
|
||||
/* Calculate header audio data size */
|
||||
framesize := (144*
|
||||
g_mpeg1_bitrates[f.header.layer][f.header.bitrate_index])/
|
||||
|
@ -39,10 +39,7 @@ var g_mpeg1_bitrates = map[mpeg1Layer][15]int{
|
||||
var g_sampling_frequency = [3]int{44100, 48000, 32000}
|
||||
|
||||
func (f *frame) readAudioL3() error {
|
||||
nch := 2
|
||||
if f.header.mode == mpeg1ModeSingleChannel {
|
||||
nch = 1
|
||||
}
|
||||
nch := f.numberOfChannels()
|
||||
/* Calculate header audio data size */
|
||||
framesize := (144*
|
||||
g_mpeg1_bitrates[f.header.layer][f.header.bitrate_index])/
|
||||
|
Loading…
Reference in New Issue
Block a user