예제 #1
0
파일: mix.go 프로젝트: go-mix/mix
// OutputContinueTo to  mix and output as []byte via stdout, up to a specified duration-since-start
func OutputContinueTo(t time.Duration) {
	deltaDur := t - outputToDur
	deltaTz := spec.Tz(masterFreq * float64((deltaDur)/time.Second))
	debug.Printf("mix.OutputContinueTo(%+v) deltaDur:%+v nowTz:%+v deltaTz:%+v begin...", t, deltaDur, nowTz, deltaTz)
	bind.OutputNext(deltaTz)
	outputToDur = t
	debug.Printf("mix.OutputContinueTo(%+v) ...done! nowTz:%+v outputToDur:%+v", t, nowTz, outputToDur)
}
예제 #2
0
파일: mix.go 프로젝트: go-mix/mix
// TODO:
// Make a new empty map[string]*Source, e.g. keepSource
// While iterating over the ready & active fires (see issues #11 and #18; implemented as of pull #29) copy any used *Source to the new keepSource
// Replace the mixSource with keepSource
func mixCycle() {
	var f *fire.Fire
	// for garbage collection of unused sources:
	keepSource := make(map[string]bool)
	// if a fire is near-to-playback, move it to the live fire queue
	keepReadyFires := make([]*fire.Fire, 0)
	for _, f = range mixReadyFires {
		keepSource[f.Source] = true
		if f.BeginTz < nowTz+masterCycleDurTz*2 { // for now, double a mix cycle is consider near-playback
			mixLiveFires = append(mixLiveFires, f)
		} else {
			keepReadyFires = append(keepReadyFires, f)
		}
	}
	mixReadyFires = keepReadyFires
	// keep only active fires
	keepLiveFires := make([]*fire.Fire, 0)
	for _, f = range mixLiveFires {
		if f.IsAlive() {
			keepSource[f.Source] = true
			keepLiveFires = append(keepLiveFires, f)
		} else {
			f.Teardown()
		}
	}
	mixLiveFires = keepLiveFires
	source.Prune(keepSource)
	nextCycleTz = nowTz + masterCycleDurTz
	if debug.Active() && source.Count() > 0 {
		debug.Printf("mix [%dz] fire-ready:%d fire-active:%d sources:%d\n", nowTz, len(mixReadyFires), len(mixLiveFires), source.Count())
	}
}
예제 #3
0
파일: source.go 프로젝트: go-mix/mix
func (s *Source) load() {
	s.state = LOADING
	s.sample, s.audioSpec = bind.LoadWAV(s.URL)
	if s.audioSpec == nil {
		// TODO: handle errors loading file
		debug.Printf("could not load WAV %s\n", s.URL)
	}
	s.maxTz = spec.Tz(len(s.sample))
	s.state = READY
}