Skip to content

Commit 2dcfd5e

Browse files
authored
Merge pull request #22 from pipelined/compatibility
Compatibility
2 parents 9aa9a65 + 7b6ce25 commit 2dcfd5e

28 files changed

+1875
-2057
lines changed

example_interate_test.go

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,24 @@ import (
99
// This example demonstrates how to iterate over the buffer.
1010
func Example_iterate() {
1111
// allocate int64 buffer with 2 channels and capacity of 8 samples per channel
12-
buf := signal.Allocator{Channels: 2, Capacity: 8}.Int64(signal.BitDepth64)
12+
buf := signal.Allocator{
13+
Channels: 2,
14+
Capacity: 8,
15+
Length: 4,
16+
}.Int64(signal.BitDepth64)
1317

1418
// write striped data
15-
buf = signal.WriteStripedInt8([][]int8{{1, 1, 1, 1}, {2, 2, 2, 2}}, buf)
19+
signal.WriteStripedInt8([][]int8{{1, 1, 1, 1}, {2, 2, 2, 2}}, buf)
1620

1721
// iterate over buffer interleaved data
18-
for pos := 0; pos < buf.Len(); pos++ {
19-
fmt.Printf("%d", buf.Sample(pos))
22+
for i := 0; i < buf.Len(); i++ {
23+
fmt.Printf("%d", buf.Sample(i))
2024
}
2125

22-
for channel := 0; channel < buf.Channels(); channel++ {
26+
for c := 0; c < buf.Channels(); c++ {
2327
fmt.Println()
24-
for pos := 0; pos < buf.Length(); pos++ {
25-
fmt.Printf("%d", buf.Sample(buf.ChannelPos(channel, pos)))
28+
for i := 0; i < buf.Length(); i++ {
29+
fmt.Printf("%d", buf.Sample(signal.BufferIndex(buf.Channels(), c, i)))
2630
}
2731
}
2832

example_read_write_test.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,16 @@ func Example_readWrite() {
1111
var output []int
1212

1313
// allocate int64 buffer with 2 channels and capacity of 8 samples per channel
14-
buf := signal.Allocator{Channels: 2, Capacity: 8}.Int64(signal.BitDepth64)
14+
buf := signal.Allocator{
15+
Channels: 2,
16+
Capacity: 8,
17+
Length: 8,
18+
}.Int64(signal.BitDepth64)
1519

1620
// write striped data
17-
buf = signal.WriteStripedInt8([][]int8{{1, 1, 1, 1}, {2, 2, 2, 2}}, buf)
21+
signal.WriteStripedInt8([][]int8{{1, 1, 1, 1}, {2, 2, 2, 2}}, buf.Slice(0, 4))
1822
// write interleaved data
19-
buf = signal.WriteInt16([]int16{11, 22, 11, 22, 11, 22, 11, 22}, buf)
23+
signal.WriteInt16([]int16{11, 22, 11, 22, 11, 22, 11, 22}, buf.Slice(4, 8))
2024

2125
output = make([]int, 16) // reset output
2226
signal.ReadInt(buf, output) // read data into output

float32.go

Lines changed: 75 additions & 61 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

float32_test.go

Lines changed: 29 additions & 26 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)