Simple WAV playing on windows

polaris · · 625 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>I&#39;ve been working with a few other folk on a game engine in go recently, and we came across the issue that many other engines have come across-- go lacks native audio support for windows. We couldn&#39;t find an engine that had solved this, and most threads we could find on the subject recommended downloading and using some c++ libraries. </p> <p>We decided we didn&#39;t want to do that, and so I&#39;ve been working on getting basic audio files playing with Direct Sound, here:</p> <p><a href="https://bitbucket.org/StephenPatrick/go-winaudio/overview">https://bitbucket.org/StephenPatrick/go-winaudio/overview</a></p> <p>This combines the work of a few others, oov, verdverm, and the unknown author of this page: <a href="http://www.rastertek.com/dx11tut14.html">http://www.rastertek.com/dx11tut14.html</a></p> <p>This is very much in its infancy, so feedback is appreciated.</p> <hr/>**评论:**<br/><br/>slimsag: <pre><p>Very cool! Always awesome to see more audio work in Go.</p> <p>(shameless plug as primary author, sorry, I just wanted to let you know they exist -- I don&#39;t really care if you use them or not) <a href="https://github.com/azul3d/engine">Azul3D</a> has a bunch of audio packages that you might find useful, in specific:</p> <ul> <li><a href="https://godoc.org/azul3d.org/engine/audio">azul3d.org/engine/audio</a> is like Go&#39;s &#34;image&#34; package but for audio (defines standard formats and data types, pure Go).</li> <li><a href="https://godoc.org/azul3d.org/engine/audio/wav">azul3d.org/engine/audio/wav</a> handles decoding and encoding of wav files (pure Go).</li> <li><a href="https://godoc.org/azul3d.org/engine/audio/flac">azul3d.org/engine/audio/flac</a> handles decoding of FLAC files (pure Go).</li> </ul> <p>Lastly, to actually play/record audio (including 3D audio), you can use <a href="https://godoc.org/azul3d.org/engine/native/al">azul3d.org/engine/native/al</a> which is cross-platform (Windows, Linux, and Mac) and while not pure Go is &#34;go get&#34;-able (no fancy installation/C dependencies are needed, they are all baked in). However, do note that this package is just 1:1 bindings to OpenAL, so it will be trickier to use than the above packages (I suggest Googling OpenAL tutorials, long term there would hopefully be a higher-level package that works with the above ones nicely).</p> <p>I like that your package looks so simple to play audio (in comparison to OpenAL, which is more featureful/complex), but a shame it&#39;s Windows only :(</p></pre>Sythe2o0: <pre><p>Thanks for sharing! We looked into azul3d when we started our engine in February, but were trying to make something in 2d, and couldn&#39;t find a function to draw an image onto a window in a 2d fashion, so we didn&#39;t look very closely at it.</p> <p>The OpenAL bindings you&#39;re linking to look like they&#39;re on a similar level as the <a href="https://godoc.org/github.com/oov/directsound-go/dsound" rel="nofollow">dsound</a> library this uses.</p> <p>This is largely an effort to use the tools that library provides and create something which doesn&#39;t require any particular audio-programming or manipulation knowledge to use. </p> <p>As for why it&#39;s windows only, we already knew about <a href="https://godoc.org/golang.org/x/mobile/exp/audio" rel="nofollow">golang.org/x/mobile/exp/audio</a>, so we didn&#39;t think writing an audio utility for non-windows would be helpful. If we make our engine open source, it&#39;s audio utility will include some kind of unified interface for different OSes. </p></pre>dericofilho: <pre><p>I see you&#39;re using syscalls. I&#39;d suggest adding compilation tags. I know the name is quite self-explanatory, still... I think it is a safe measure. </p></pre>

入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889

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