Libsndfile Problem

Hello!

I've been recently trying to learn some sound programming and everything that revolves around it so I
decided to use libsndfile since it seemed so easy.

I set up my environment and downloaded the win32 (using windows 7 x64) binary package on the website
(http://www.mega-nerd.com/libsndfile/) and installed it. Copied the libs and include files etc.

Now here is where the problems come, to make the libsndfile work you need to include the <sndfile.h>
header file and link to the libsndfile-1.lib file.

When I thereafter try to compile the project (using Visual Studio 2008 Professional Edition) I receive
an error whenever I instantiate the SNDFILE structure. It is defined as this in the header file:
1
2
3
4
extern "C"
{
 typedef struct SNDFILE_tag SNDFILE;
}
Or if preferred the entire file exists here: http://api.vemus.org/CoreServices/sndfile_8h-source.html

So when I use this code:SNDFILE sf = NULL;

This is the error I receive:
error C2079: 'sf' uses undefined struct 'SNDFILE_tag'

I've searched but haven't found anyone with similar problems nor any solutions.

Any help is appreciated!
Could you display the file that you are using SNDFILE sf = NULL;?

Make sure that you are not including sndfile.h more than once.
Are you sure you meant to make a SNDFILE object? Perhaps you're supposed to use a SNDFILE pointer:

 
SNDFILE* sf = NULL; // note the * 
I am sure of that the file is only included once and from what I understand from the
compiler errors the problem seem to lay in the header (sndfile.h).

I only use methods and member from the sndfile header in the LoadSound function exclusively
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// Custom Includes
#include "sound.h"
#include "error.h"

// For Wav File
#include <MMSystem.h>

// Testing (libsndfile)
#include <sndfile.h>

// For OGG File
#include <vorbis/vorbisfile.h>

// Static Members
IXAudio2 * Sound::m_pXAudio;
IXAudio2MasteringVoice * Sound::m_pMasterVoice;
int Sound::m_classes;

// Constructor
Sound::Sound(void) : m_pSourceVoice(NULL), m_pBuffer(NULL), m_bufferSize(0)
{
    ...
}

// Destructor
Sound::~Sound(void)
{
   ...
}

bool Sound::LoadSound(const char * soundFile, SoundType::Type type, BYTE loopCount)
{
   switch(type)
   {
      case SoundType::WAV:
      {
         // Info Struct and File Handle
         SF_INFO info = {0};
         SNDFILE sf = NULL;
			
         if((sf = sf_open(soundFile, SFM_READ, &info)) == NULL)
         {
            APPERROR::DisplayError(16);
            return 0;
         }

         // Buffer Size
         m_bufferSize = info.frames * info.channels * sizeof(int);

         break;
      }
   }
}
Since the libsndfile.lib includes the ogg vorbis library statically it might perhaps have something to do with that (i link it dynamically).

And the reason why I include the ogg vorbis header when libsndfile supports ogg is because
I need to check that libsndfile is compatible with the XAudio2 Interface.
1
2
3
         SNDFILE sf = NULL;
			
         if((sf = sf_open(soundFile, SFM_READ, &info)) == NULL)


Yes... now I am 99.9999999% certain I was correct.

sf needs to be a pointer:

 
SNDFILE* sf = NULL;
Topic archived. No new replies allowed.