pcm: removed unused sample formats

This commit is contained in:
Trek H 2019-11-13 14:00:52 +10:30
parent 678245c634
commit 3a7c2c5c5e
1 changed files with 4 additions and 84 deletions

View File

@ -43,26 +43,10 @@ const (
Unknown SampleFormat = -1
)
// Common sample formats that are used.
// Sample formats that we use.
const (
S8 SampleFormat = iota
U8
S16_LE
S16_BE
U16_LE
U16_BE
S24_LE
S24_BE
U24_LE
U24_BE
S16_LE SampleFormat = iota
S32_LE
S32_BE
U32_LE
U32_BE
FLOAT_LE
FLOAT_BE
FLOAT64_LE
FLOAT64_BE
// There are many more:
// https://linux.die.net/man/1/arecord
// https://trac.ffmpeg.org/wiki/audio%20types
@ -212,87 +196,23 @@ func gcd(a, b int) int {
// String returns the string representation of a SampleFormat.
func (f SampleFormat) String() string {
switch f {
case S8:
return "S8"
case U8:
return "U8"
case S16_LE:
return "S16_LE"
case S16_BE:
return "S16_BE"
case U16_LE:
return "U16_LE"
case U16_BE:
return "U16_BE"
case S24_LE:
return "S24_LE"
case S24_BE:
return "S24_BE"
case U24_LE:
return "U24_LE"
case U24_BE:
return "U24_BE"
case S32_LE:
return "S32_LE"
case S32_BE:
return "S32_BE"
case U32_LE:
return "U32_LE"
case U32_BE:
return "U32_BE"
case FLOAT_LE:
return "FLOAT_LE"
case FLOAT_BE:
return "FLOAT_BE"
case FLOAT64_LE:
return "FLOAT64_LE"
case FLOAT64_BE:
return "FLOAT64_BE"
default:
return fmt.Sprintf("Invalid FormatType (%d)", f)
return "Unknown"
}
}
// SFFromString takes a string representing a sample format and returns the corresponding SampleFormat.
func SFFromString(s string) (SampleFormat, error) {
switch s {
case "S8":
return S8, nil
case "U8":
return U8, nil
case "S16_LE":
return S16_LE, nil
case "S16_BE":
return S16_BE, nil
case "U16_LE":
return U16_LE, nil
case "U16_BE":
return U16_BE, nil
case "S24_LE":
return S24_LE, nil
case "S24_BE":
return S24_BE, nil
case "U24_LE":
return U24_LE, nil
case "U24_BE":
return U24_BE, nil
case "S32_LE":
return S32_LE, nil
case "S32_BE":
return S32_BE, nil
case "U32_LE":
return U32_LE, nil
case "U32_BE":
return U32_BE, nil
case "FLOAT_LE":
return FLOAT_LE, nil
case "FLOAT_BE":
return FLOAT_BE, nil
case "FLOAT64_LE":
return FLOAT64_LE, nil
case "FLOAT64_BE":
return FLOAT64_BE, nil
default:
return Unknown, errors.Errorf("Unknown FormatType (%s)", s)
return Unknown, errors.Errorf("unknown sample format (%s)", s)
}
}