0

here is my problem. I am trying to set up a stream to play in my program. It worked well once, then I changed the name of my class and now it does not work anymore and I get error 30 from the result. I cannot find any explanations on why it worked before and now it does not. Here is my SoundStream.h

#include "fmod.hpp"
#include "common.h"
#include <iostream>

class SoundStream
{
public:
    FMOD::System     *system,*sys;
    FMOD::Sound      *sound, *sound_to_play;
    FMOD::Channel    *channel = 0;
    FMOD_RESULT       result;

    void startStream()
    {
        result = system->init(32, FMOD_INIT_NORMAL, 0);
        std::cout << result << std::endl;
        result = system->createStream("singing.wav", FMOD_LOOP_NORMAL |         FMOD_2D, 0, &sound);
        std::cout << result << std::endl;
        sound_to_play = sound;
        result = system->playSound(sound_to_play, 0, false, &channel);
        std::cout << result << std::endl;
        std::cout << "Working" << std::endl;
    }
};

Created it like this in my other function:

SoundStream soundStream;
soundStream.startStream();

Everything is linked correctly.

Thanks

Nico
  • 27
  • 7

1 Answers1

0

It seems like you're not creating the System object:

System_Create(&system);

Also the arguments you're passing to System::playSound are not valid (I'm using FMOD 4.44.58-1).

Here is a working example:

#include "fmod.hpp"

class SoundStream
{
public:
  FMOD::System     *system;
  FMOD::Sound      *sound;
  FMOD::Channel    *channel;

  void startStream()
  {
    System_Create(&system);
    system->init(32, FMOD_INIT_NORMAL, 0);
    system->createStream("singing.wav", FMOD_LOOP_NORMAL | FMOD_2D, 0, &sound);
    system->playSound(FMOD_CHANNEL_REUSE, sound, false, &channel);
  }
};

int main(int argc, char** argv)
{
  SoundStream soundStream;
  soundStream.startStream();

  while(true) {} // ctrl + c to exit
  return 0;
}
AndreLDM
  • 2,117
  • 1
  • 18
  • 27