Debian Codegraph @

examples/samplespec.go

raw symbols SCIP
1 package main
2
3 import (
4 ".." // pulse-simple
5 "fmt"
6 )
7
8 func main() {
9 fmt.Printf("spec1 := SampleSpec{SAMPLE_S16LE,44100,2}\n")
10 spec1 := create_spec(pulse.SAMPLE_S16LE, 44100, 2)
11 print_info(spec1)
12
13 fmt.Printf("\nspec2 := SampleSpec{SAMPLE_FLOAT32,96000,6}\n")
14 spec2 := create_spec(pulse.SAMPLE_FLOAT32, 96000, 6)
15 print_info(spec2)
16
17 fmt.Printf("\nspec1.Equal(spec2): %v\n", spec1.Equal(spec2))
18 fmt.Printf("spec3 := SampleSpec{SAMPLE_S16LE,44100,2}\n")
19 spec3 := create_spec(pulse.SAMPLE_S16LE, 44100, 2)
20 fmt.Printf("spec3.Equal(spec1): %v\n", spec3.Equal(spec1))
21
22 fmt.Printf("\nspec4 := SampleSpec{SAMPLE_U8,5001,1}\n")
23 spec4 := create_spec(pulse.SAMPLE_U8, 5001, 1)
24 print_info(spec4)
25 }
26
27 func create_spec(f pulse.SampleFormat, r uint32, c uint8) *pulse.SampleSpec {
28 return &pulse.SampleSpec{f, r, c}
29 }
30
31 func print_info(spec *pulse.SampleSpec) {
32 fmt.Printf("String: %v\n", spec.String())
33 fmt.Printf("Valid: %v\n", spec.Valid())
34 fmt.Printf("BytesPerSecond: %v\n", spec.BytesPerSecond())
35 fmt.Printf("FrameSize: %v\n", spec.FrameSize())
36 fmt.Printf("SampleSize: %v\n", spec.SampleSize())
37 fmt.Printf("BytesToUsec(64): %v\n", spec.BytesToUsec(64))
38 fmt.Printf("UsecToBytes(100): %v\n", spec.UsecToBytes(100))
39 fmt.Printf("SampleFormat: %s\n", spec.Format.String())
40 fmt.Printf("Format SampleSize: %v\n", spec.Format.SampleSize())
41 fmt.Printf("Little-endian: %v\n", spec.Format.IsLe())
42 fmt.Printf("Big-endian: %v\n", spec.Format.IsBe())
43 fmt.Printf("Native-endian: %v\n", spec.Format.IsNe())
44 fmt.Printf("Reverse-endian: %v\n", spec.Format.IsRe())
45 }