MCPcopy
hub / github.com/EngoEngine/engo / Decode

Function Decode

common/internal/decode/mp3/decode.go:57–71  ·  view source on GitHub ↗

Decode decodes MP3 source and returns a decoded stream. Decode returns error when decoding fails or IO error happens. Decode automatically resamples the stream to fit with the audio context if necessary.

(src convert.ReadSeekCloser, sr int)

Source from the content-addressed store, hash-verified

55//
56// Decode automatically resamples the stream to fit with the audio context if necessary.
57func Decode(src convert.ReadSeekCloser, sr int) (*Stream, error) {
58 d, err := mp3.NewDecoder(src)
59 if err != nil {
60 return nil, err
61 }
62 var r *convert.Resampling
63 stream := &Stream{
64 orig: d,
65 resampling: r,
66 }
67 if d.SampleRate() != sr {
68 stream.resampling = convert.NewResampling(stream, stream.orig.Length(), stream.orig.SampleRate(), sr)
69 }
70 return stream, nil
71}

Callers 1

LoadMethod · 0.92

Calls 2

NewResamplingFunction · 0.92
LengthMethod · 0.45

Tested by

no test coverage detected