SDL_Mixer 声音问题
基本信息:
编程语言 - C++
平台 - Windows
音频格式 - wav 和 mid
我最近完成了一个游戏,并正在寻找将其上传到文件托管站点的最佳方法。我最终决定使用 7zip 的自解压功能。但是,我认为我犯的错误是,我没有将需要的内容复制到另一个文件夹并将其压缩以供分发(即不复制源文件等),而是重新排列了保存所有源文件的实际文件夹等等,并将其分成 2 个 C++ 文件子文件夹,然后是其他所有内容(该文件夹是被压缩的文件夹。)
我测试了下载它并播放它,它工作正常。然而,我回去了,因为我决定改变背景音乐,这就是问题开始发生的时候。
总结一下问题,Mix_PlayMusic()
正在被调用并且工作正常。但是,由于某种原因,没有声音播放(也没有从 Mix_PlayChannel()
调用任何声音效果)。奇怪的是,当调用 Mix_FadeOutMusic()
时,您可以听到音乐。我也有一个声音切换功能,但经过彻底的测试后,我得出的结论是这不是问题。
我最终决定创建一个全新的项目,并将我需要的所有文件放入该项目中与最初所在的同一“组织”中。然而,问题仍然存在。
我不知道出了什么问题。文件加载正常,只是当音乐应该播放时(根据测试确实如此),它没有播放。这也适用于声音效果。
编辑:我实际上为每个游戏循环编写了一个测试,以确定音乐是否正在播放以及显然音乐正在播放。只是由于某种原因没有被听到。
Basic Info:
Programming Language - C++
Platform - Windows
Audio Formats - wav and mid
I recently finished a game and was fooling around with figuring out the best way to upload it to a file hosting site. I eventually decided on using 7zip's self-extracting feature. However, I think the mistake I made was that instead of just copying what I needed to another folder and zipping that up for the distribution (i.e., not copying source files, etc.) I rearranged the actual folder that held all of my source files etc. and split it into 2 sub folders for the C++ files, and then everything else (that folder being the one that got zipped up.)
I tested downloading it and playing it and it worked fine. However, I went back because I decided to change the background music and that's when the problem started happening.
To sum the problem up, Mix_PlayMusic()
is being called and is working correctly. However, for some reason no sound is playing (and neither are any of the sound effects called from Mix_PlayChannel()
). The odd thing is that you can hear the music when Mix_FadeOutMusic()
is called. I also have a sound toggling feature, but after thorough testing I've come to the conclusion that it isn't the problem.
I finally decided to create a completely new project and just bring all of the files I needed into that project in the same "organization" that they were in originally. However, the problem is still there.
I have no idea what's wrong. The files are being loaded in fine, it's just that when the music is supposed to be playing (and according to testing it is), it's not playing. This also applies to sound effects.
Edit: I actually wrote a test for each game loop for whether the music is playing and apparently the music is playing. It's just that for some reason it isn't being heard.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这可能有很多原因。这可能是您拥有的 SDL_Mixer 库的问题,因此您可以尝试再次获取它以排除该问题。您的音量可能在某个地方被设置为零,所以我会检查音量作为测试。最后的想法是您正在播放的源声音文件在某种程度上不兼容(如果您可以在另一个声音播放器中播放它,则不太可能,但有可能)。除了这些建议之外,我认为我无法利用您提供的数据为您提供任何进一步的帮助。
This could be a number of things. It could be an issue with the SDL_Mixer library you have, so you could try getting it again to rule that out. Your volume may have somehow got set to zero somewhere, so I would check the volume as a test. And the final thought would be that the source sound file you are playing is incompatible in some way (not likely if you can play it in another sound player, but possible). Besides those suggestions I don't believe I can help you any further with the data you have provided.