如何在 C# 中播放 nsf 音乐? (制作游戏)
我正在和一些朋友为我们最后一个高中项目制作一个游戏。 我无法找到如何播放我用 C# 编写的音乐,我正在这里寻求答案。
我们使用的是 Microsoft Visual studio 2010,这段时间我主要为游戏编写音乐,所以我在 C# 编程方面还是个初学者。
我制作的音乐是用一个名为 Famitracker 的程序制作的,不知道您是否熟悉它,但我可以将文件导出到 NSF,这很好,因为它们占用的磁盘空间很小。
所以我真正的问题是如何让我们的游戏播放音乐并循环播放直到游戏进入下一阶段?
I'm making a game with some friends for our last highschool project .
I'm having trouble finding out how to play the music I've written in c# and I'm turning here for answers.
We're using Microsoft Visual studio 2010, and I've mainly been writing music for the game during this time so I'm quite a beginner at programming in C#.
The Music I've made is made in a program called Famitracker don't know if your familiar with it but I can export the files to NSF which is good since they take up low disk space.
So my real question is how do I make our game play the music and loop it until the play gets to the next stage?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
NSF 或 任天堂声音格式 不是 Windows 或 .NET 本身支持的格式...相反您必须编写或找到自己的播放器...或者以更常见的格式(例如 MP3 或 WAV)重做您的音乐。
如果您想坚持使用 NSF,我建议您查看其中一款开源 NES 模拟器,看看您是否无法使用他们的代码。 (示例 1) (示例 2) (示例 3)
NSF, or the Nintendo Sound Format is not something that Windows nor .NET supports natively... instead you would have to either write or find your own player for it... or redo your music in something more common like MP3 or WAV.
If you want to stick with NSF, I'd suggest looking at one of the open source NES emulators out there and see if you can't use of of their code. (Example 1) (Example 2) (Example 3)
最简单的解决方案可能是将其输出为 wav 并使用 XNA 播放它,如 Matthew 所描述的那样。文件大小可能会更大,但除非您遇到文件大小问题,否则我认为这将是迄今为止最简单的方法。在 C# 中似乎没有任何简单的 nsf 播放器实现,尽管您可能会研究 NES 模拟器是如何做到这一点的。
Your easiest solution would probably be to output is as a wav and play it using XNA as Matthew describes. The file size may be larger, but unless you are having file size issues, I think that will by far be the easiest way to go. There doesn't seem to be any easy implementation of a nsf player in C#, although you might look into how NES emulators are doing it.
在游戏中使用XNA框架进行音频等。
这是一个很好的起点: http://www.google.com/search?sourceid=chrome&ie=UTF-8&q=xna+framework+play+audio
Use the XNA framework for audio, etc in games.
Here is a good starting point: http://www.google.com/search?sourceid=chrome&ie=UTF-8&q=xna+framework+play+audio