[Question] Reproducing sound

xuanbao · · 505 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>I&#39;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&#39;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&#39;m usually on OSX or GNU/Linux)</p> <hr/>**评论:**<br/><br/>dasacc22: <pre><p>I think you&#39;ll be looking at bindings one way or another to go crossplatform. I&#39;m not sure of status of openal on windows from gomobile project, but that&#39;s what I&#39;m currently using over on github.com/dskinner/snd</p></pre>coppolaemilio: <pre><p>Thanks! I&#39;ll check it out. I&#39;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&#39;ll be making use of some kind of binding. I don&#39;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&#39;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

505 次点击  
加入收藏 微博
暂无回复
添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传