Welcome
Welcome to a320

You are currently viewing our boards as a guest, which gives you limited access to view most discussions and access our other features. By joining our free community, you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content, and access many other special features. Registration is fast, simple, and absolutely free, so please, join our community today!

Illegal calls?

Any and all A320 homebrew topics

Moderator: Moderators

Illegal calls?

Postby Wiredbomb0 on Sat May 16, 2009 3:14 pm

I keep getting this error when I try to compile my source:

Code: Select all
error C2352: 's2d::AudioData::LoadPCM' : illegal call of non-static member function


The code for that section is:

Code: Select all
   AudioPlayer::Init();
   Char* file = "bgmusic.pcm";
   s2d::AudioData* song = AudioData::LoadPCM(file);


What am I doing wrong?
Wiredbomb0
 
Posts: 166
Joined: Thu Apr 23, 2009 10:08 am
Location: Victoria, Australia

Re: Illegal calls?

Postby joyrider on Sun May 17, 2009 10:39 am

you have to use an instance of the audio player, there is actually one made for you when using the GameEngine. But you can not instanciate a new instance directly from it. you first have to make a derived class.

like this for example (i'm using it).

GameEngine.h
Code: Select all
#ifndef GAMEENGINE_H
#define GAMEENGINE_H

#include "./s2d/s2d.h"

class GameEngine : public Engine
{
   public:
      GameEngine( void* userdata [] );
      ~GameEngine( void );
      result   Init( void );
      void   Free( void );
      void   Exec( void );
      void   Exec2( void );
      void   PreRender( void );
      void   Render( void );
      void   PostRender( void );
};

#endif


GameEngine.cpp
Code: Select all
#include "GameEngine.h"

GameEngine::GameEngine( void* userdata [] ): Engine( userdata )
{
}

GameEngine::~GameEngine( void )
{
}

result   GameEngine::Init( void )
{
   return S2D_OK;
}

void   GameEngine::Free( void )
{
}

void   GameEngine::Exec( void )
{
}

void   GameEngine::Exec2( void )
{
}

void   GameEngine::PreRender( void )
{
}

void   GameEngine::Render( void )
{
}

void   GameEngine::PostRender( void )
{
}


add these files to your project and in your main cpp file "include" it.

then to make audio work :
Code: Select all
//somewhere in your init code
//instance
AudioData* SomeSound = new AudioData();
//load a 16000khz, 16 bit signed mono raw pcm file (at least that's what i use and seems to work)
SomeSound ->LoadPCM(_LS("something.snd"));

//somewhere in your "game" loop
//Play the sound, g_pEng is an engine instance of the class above this. You can look up what the values are that are given here
g_pEng->m_pAudioPlayer->Play(SomeSound ,1,SomeSound ->GetSize(),255,false);

//When you quit your "game"
//at the end delete the some sound
SAFE_DELETE(SomeSound);
joyrider
 
Posts: 77
Joined: Sun May 03, 2009 4:27 pm

Re: Illegal calls?

Postby Wiredbomb0 on Sun May 17, 2009 10:52 am

I had figured this out earlier today infact, such as silly mistake. Thanks for your help!
Wiredbomb0
 
Posts: 166
Joined: Thu Apr 23, 2009 10:08 am
Location: Victoria, Australia


Return to Homebrew

Who is online

Users browsing this forum: nine10 and 2 guests