Checkpoint
This commit is contained in:
125 files changed
+59376
No files matched your search
@@ -0,0 +1,35 @@
|
||||
package audio
|
||||
|
||||
// Deinterleave multi channel samples to separate slices.
|
||||
func Deinterleave(samples []int16, slices [][]int16) {
|
||||
if len(samples) == 0 {
|
||||
return
|
||||
}
|
||||
if len(slices) == 1 {
|
||||
copy(slices[0], samples)
|
||||
return
|
||||
}
|
||||
|
||||
channels := len(slices)
|
||||
for i, sample := range samples {
|
||||
j, k := i%channels, i/channels
|
||||
slices[j][k] = sample
|
||||
}
|
||||
}
|
||||
|
||||
// Interleave multi channel samples to a single slice.
|
||||
func Interleave(slices [][]int16, samples []int16) {
|
||||
if len(slices) == 0 {
|
||||
return
|
||||
}
|
||||
if len(slices) == 1 {
|
||||
copy(samples, slices[0])
|
||||
return
|
||||
}
|
||||
|
||||
channels := len(slices)
|
||||
for i := range samples {
|
||||
j, k := i%channels, i/channels
|
||||
samples[i] = slices[j][k]
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user