ctrestain
9th December 2011, 22:04
Hey. I'm still kind of a newbie with this stuff. I got fmod to work with dev c++ just fine, but i'm having trouble with Qt. I just need to be able to play a .wav file and i'll be good to go. Here is the code i'm using so far. It runs fine but makes a beeping sound instead of the sound I want it to play.
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "QPainter.h"
#include "inc/fmod.h"
#include "inc/fmod_dsp.h"
#include "inc/fmod_errors.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
}
MainWindow::~MainWindow()
{
delete ui;
}
void ERRCHECK(FMOD_RESULT result)
{
if (result != FMOD_OK)
{
printf("FMOD error! (%d) %s\n", result, FMOD_ErrorString(result));
exit(-1);
}
}
void MainWindow::paintEvent(QPaintEvent *)
{
QPainter p(this);
p.setPen(Qt::black);
p.setBrush(Qt::black);
FMOD_SYSTEM *system;
FMOD_SOUND *snare1;
FMOD_CHANNEL *channel = 0;
FMOD_RESULT result;
result = FMOD_System_Create(&system);
ERRCHECK(result);
result = FMOD_System_Init(system, 32, FMOD_INIT_NORMAL, NULL);
ERRCHECK(result);
result = FMOD_System_CreateSound(system, "drums/snare1.wav", FMOD_SOFTWARE, 0, &snare1);
ERRCHECK(result);
result = FMOD_System_PlaySound(system, FMOD_CHANNEL_FREE, snare1, 0, &channel);
ERRCHECK(result);
}
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "QPainter.h"
#include "inc/fmod.h"
#include "inc/fmod_dsp.h"
#include "inc/fmod_errors.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
}
MainWindow::~MainWindow()
{
delete ui;
}
void ERRCHECK(FMOD_RESULT result)
{
if (result != FMOD_OK)
{
printf("FMOD error! (%d) %s\n", result, FMOD_ErrorString(result));
exit(-1);
}
}
void MainWindow::paintEvent(QPaintEvent *)
{
QPainter p(this);
p.setPen(Qt::black);
p.setBrush(Qt::black);
FMOD_SYSTEM *system;
FMOD_SOUND *snare1;
FMOD_CHANNEL *channel = 0;
FMOD_RESULT result;
result = FMOD_System_Create(&system);
ERRCHECK(result);
result = FMOD_System_Init(system, 32, FMOD_INIT_NORMAL, NULL);
ERRCHECK(result);
result = FMOD_System_CreateSound(system, "drums/snare1.wav", FMOD_SOFTWARE, 0, &snare1);
ERRCHECK(result);
result = FMOD_System_PlaySound(system, FMOD_CHANNEL_FREE, snare1, 0, &channel);
ERRCHECK(result);
}