why doesnt it work

View: New views
1 Messages — Rating Filter:   Alert me  

why doesnt it work

by Addy87 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,
i have the following code

engine.h:
Code:
#include <string>
#include <iostream>
#include <AL/al.h>
#include <AL/alut.h>
#include <vector>

class SoundNode
{

    public:
     SoundNode();
     ~SoundNode();
     void setSound(char *new_sound);
     void setSourcePosition(ALfloat new_x, ALfloat new_y, ALfloat new_z);
     void play(void);

     char *Sound;


     private:
    ALfloat ListenerPosition[3];
    ALfloat ListenerVelocity[3];
    ALfloat ListenerOrientation[6];
    void KillAlData(void);
    void setListenerValues(void);



    ALuint *Buffer;

    ALuint *Source;


    ALenum *format;
    ALsizei *size;
    ALvoid* data;
    ALsizei *freq;
    ALboolean *loop;

};




engine.cpp:
Code:
#include <string>
#include <AL/al.h>
#include <AL/alut.h>
#include <vector>
#include "Engine.h"



SoundNode::SoundNode(void)
{
this->ListenerPosition[0]=0.0;
this->ListenerPosition[1]=0.0;
this->ListenerPosition[2]=0.0;

this->Sound=NULL;

}


SoundNode::~SoundNode(void)
{
delete [] this->Sound;
delete this->Buffer;
delete this->Source;
delete this->format;
delete this->size;
delete this->data;
delete this->freq;
delete this->loop;
delete this;
}

void SoundNode::setSourcePosition(ALfloat new_x, ALfloat new_y, ALfloat new_z)
{
    this->ListenerPosition[0]=new_x;
    this->ListenerPosition[1]=new_y;
    this->ListenerPosition[2]=new_z;

}

void SoundNode::setSound(char* new_sound)
{
    this->Sound = new char[strlen(new_sound) + 1];
    strcpy(this->Sound,new_sound);
}



void SoundNode::play(void)
{
alutInit(0,0);
setListenerValues();
alSourcePlay(*this->Source);

}


void SoundNode::setListenerValues(void)
{
    alListenerfv(AL_POSITION,    this->ListenerPosition);
    alListenerfv(AL_VELOCITY,    this->ListenerVelocity);
    alListenerfv(AL_ORIENTATION, this->ListenerOrientation);
}






demo.cpp:
Code:
#include <string>
#include <iostream>
#include <AL/al.h>
#include <AL/alut.h>
#include <vector>
#include "Engine.h"

int main(int argc, char *argv[])
{

    SoundNode *sound;
    sound->setSound("C:/a.wav");
    sound->play();

}
I can compile it but the sound doesnt play.
Please help me