mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 03:08:54 +01:00
audio: Add comments (#199)
This commit is contained in:
parent
b0178e8425
commit
5ae624b891
@ -39,12 +39,14 @@ func (s *Stream) Close() error {
|
|||||||
return s.decoded.Close()
|
return s.decoded.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Should be int?
|
// Size returns the size of decoded stream in bytes.
|
||||||
func (s *Stream) Size() int64 {
|
func (s *Stream) Size() int64 {
|
||||||
return s.decoded.Size()
|
return s.decoded.Size()
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: src should be ReadCloser?
|
// Decode decodes Ogg/Vorbis data to playable stream.
|
||||||
|
//
|
||||||
|
// The sample rate must be same as that of audio context.
|
||||||
func Decode(context *audio.Context, src audio.ReadSeekCloser) (*Stream, error) {
|
func Decode(context *audio.Context, src audio.ReadSeekCloser) (*Stream, error) {
|
||||||
decoded, channelNum, sampleRate, err := decode(src)
|
decoded, channelNum, sampleRate, err := decode(src)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
|
|
||||||
// +build !js
|
// +build !js
|
||||||
|
|
||||||
|
// Package vorbis provides Ogg/Vorbis decoder.
|
||||||
package vorbis
|
package vorbis
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
|
// Package vorbis provides WAV (RIFF) decoder.
|
||||||
package wav
|
package wav
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@ -43,10 +44,15 @@ func (s *Stream) Close() error {
|
|||||||
return s.src.Close()
|
return s.src.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Size returns the size of decoded stream in bytes.
|
||||||
func (s *Stream) Size() int64 {
|
func (s *Stream) Size() int64 {
|
||||||
return s.dataSize
|
return s.dataSize
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Decode decodes WAV (RIFF) data to playable stream.
|
||||||
|
//
|
||||||
|
// The format must be 2 channels, 16bit little endian PCM.
|
||||||
|
// The sample rate must be same as that of audio context.
|
||||||
func Decode(context *audio.Context, src audio.ReadSeekCloser) (*Stream, error) {
|
func Decode(context *audio.Context, src audio.ReadSeekCloser) (*Stream, error) {
|
||||||
buf := make([]byte, 12)
|
buf := make([]byte, 12)
|
||||||
n, err := io.ReadFull(src, buf)
|
n, err := io.ReadFull(src, buf)
|
||||||
|
Loading…
Reference in New Issue
Block a user