<p>I'm wondering if there is a native way for golang to play a sound, wav, mp3, ogg, whatever. I want to make a little command line metronome and I don't really want to include sdl or any other big library. Do you guys know about a simple straightforward way of doing this cross platform? (I'm usually on OSX or GNU/Linux)</p>
<hr/>**评论:**<br/><br/>dasacc22: <pre><p>I think you'll be looking at bindings one way or another to go crossplatform. I'm not sure of status of openal on windows from gomobile project, but that's what I'm currently using over on github.com/dskinner/snd</p></pre>coppolaemilio: <pre><p>Thanks! I'll check it out. I'll probably end up using Python since it is pre-installed in most linux distros and OSX</p></pre>dasacc22: <pre><p>its the same deal with python, you'll be making use of some kind of binding. I don't know what your goal is exactly but either should work. If your looking for a quick one off you can customize in Go, there's this example from my repo:</p>
<p><a href="https://github.com/dskinner/snd/blob/master/example/oscil/main.go" rel="nofollow">https://github.com/dskinner/snd/blob/master/example/oscil/main.go</a></p>
<p>That plays a 440hz tone and for a cheap metronome effect you could just change these lines</p>
<pre><code>osc := snd.NewOscil(sine, 440, nil) // oscillator
al.AddSource(osc)
</code></pre>
<p>to this instead</p>
<pre><code>osc := snd.NewOscil(sine, 440, nil) // oscillator
dmp := snd.NewDamp(snd.BPM(80).Dur(), osc)
al.AddSource(dmp)
</code></pre></pre>
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889
- 请尽量让自己的回复能够对别人有帮助
- 支持 Markdown 格式, **粗体**、~~删除线~~、
`单行代码`
- 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
- 图片支持拖拽、截图粘贴等方式上传