Esempio n. 1
0
package ibxm

import (
	"github.com/vova616/GarageEngine/engine/audio"
	"github.com/vova616/ibxmgo"
	"os"
)

var test = audio.AudioClip(&IBXM{})

type IBXM struct {
	ibxm        *ibxmgo.IBXM
	audioBuffer []int32
	format      audio.Format
	length      int
}

func NewClip(path string) (*IBXM, error) {
	mr, e := os.Open(path)
	if e != nil {
		return nil, e
	}
	mod, e := ibxmgo.Decode(mr)
	if e != nil {
		return nil, e
	}

	clip, e := ibxmgo.NewIBXM(mod, 48000)
	if e != nil {
		return nil, e
	}
Esempio n. 2
0
package wav

import (
	"encoding/binary"
	"fmt"
	"github.com/vova616/GarageEngine/engine/audio"
	"io"
	"os"
)

var test = audio.AudioClip(&Wav{})

type Wav struct {
	Format
	Data        []int16
	index       int
	audioFormat audio.Format
}

func (this *Wav) BufferLength() int {
	return int(this.Format.SampleRate) / 2
}

func (this *Wav) NextBuffer(buff []int16, mono bool) int {
	if mono && this.audioFormat != audio.Mono16 {
		panic("does not support stereo to mono conversion")
	}

	n := copy(buff, this.Data[this.index:])
	this.index += n
	if this.index >= len(this.Data) {