【发布时间】:2015-08-30 17:32:40
【问题描述】:
我无法让SDL_Mixer 在树莓派上播放声音。该程序可以编译并构建,但我听到的只是一声短促的吱吱声(像静态的),什么也没有。
有什么想法吗?
#include <SDL/SDL.h>
#include <SDL/SDL_mixer.h>
#include <stdio.h>
#include <string>
#include <iostream>
int main()
{
Mix_Chunk *snd1 = NULL;
Mix_Music *m = NULL;
if(SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO) < 0) {
std::cout << "Something went wrong";
}
if(Mix_OpenAudio(44100, MIX_DEFAULT_FORMAT, 2, 1024) < 0) {
std::cout << "Kunne ikke loade musikk";
}
snd1 = Mix_LoadWAV("bicycle_bell.wav");
if(snd1 == NULL) {
std::cout << "Fant ikke filen";
}
Mix_PlayChannel(-1, snd1, 0);
Mix_FreeChunk(snd1);
Mix_Quit();
return 1;
}
【问题讨论】:
-
您应该在每次流写入后添加
std::endl或std::flush。你的程序可能想告诉你一些事情。 -
完成,但没有消息。
标签: c++ raspberry-pi sdl sdl-mixer