Play recorded sounds: Difference between revisions
Content added Content deleted
No edit summary |
(Added Go) |
||
Line 130: | Line 130: | ||
sndPlaySound('SoundFile.wav', SND_NODEFAULT OR SND_ASYNC); |
sndPlaySound('SoundFile.wav', SND_NODEFAULT OR SND_ASYNC); |
||
end.</lang> |
end.</lang> |
||
=={{header|Go}}== |
|||
{{trans|PicoLisp}} |
|||
<br> |
|||
Go doesn't have any audio support in its standard library and it's best therefore to invoke a utility such as SoX to complete a task such as this. |
|||
Although there is at least one third party library which provides Go bindings to the libsox sound library, for casual use it's far easier to invoke SoX directly with a list of arguments. |
|||
See the PicoLisp entry for a description of what these particular arguments do. |
|||
<lang go>package main |
|||
import ( |
|||
"log" |
|||
"os" |
|||
"os/exec" |
|||
) |
|||
func main() { |
|||
args := []string{ |
|||
"-m", "-v", "0.75", "a.wav", "-v", "0.25", "b.wav", |
|||
"-d", |
|||
"trim", "4", "6", |
|||
"repeat", "5", |
|||
} |
|||
cmd := exec.Command("sox", args...) |
|||
cmd.Stdout = os.Stdout |
|||
cmd.Stderr = os.Stderr |
|||
if err := cmd.Run(); err != nil { |
|||
log.Fatal(err) |
|||
} |
|||
}</lang> |
|||
=={{header|GUISS}}== |
=={{header|GUISS}}== |