-
Notifications
You must be signed in to change notification settings - Fork 0
/
modifiers.go
36 lines (29 loc) · 1.27 KB
/
modifiers.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package sound
import (
"github.com/splace/signals"
"time"
)
// returns a Sound that is another Sound with silence prepended.
func Delayed(source Sound, offset time.Duration) Sound {
return Sound(signals.Offset{source, signals.X(offset.Seconds())})
}
// returns a Sound that is another Sound rate adjusted.
func Spedup(source Sound, factor float32) Sound {
return Sound(signals.Compressed{source, factor})
}
// returns a Delayed Sound, so it starts just as another sounds ends.
func After(waitedFor, source Sound) Sound {
return Delayed(source, time.Duration(waitedFor.MaxX()))
}
// returns a Delayed Sound, so it starts from an offset after another sounds ends.
func AfterPlusOffset(waitedFor, source Sound, offset time.Duration) Sound {
return Delayed(source, time.Duration(waitedFor.MaxX())+offset)
}
// returns a sound in reversed.
func Reversed(source Sound) Sound {
return NewSound(signals.Shifted{signals.Reversed{source}, source.MaxX()}, time.Duration(source.MaxX()))
}
// returns a sound that is rate adjusted depending on the value of a signal, potentially another sound.
func Modulated(source Sound, modulation signals.Signal, factor time.Duration) Sound {
return NewSound(signals.RateModulated{source, modulation, signals.X(factor.Seconds())}, time.Duration(source.MaxX()))
}