Audiere; LNK2028-error

Hello!

I develope my program using Virtual C++ 2008 Express.
I use one library "libsndfile" (http://www.mega-nerd.com/libsndfile/) and another library called Audiere.
  When I compile I get the following errors:
  ------

 1>Linking...
 1>Ljudtestet3.obj : warning LNK4248: unresolved typeref token (0100002A) for 'SNDFILE_tag'; image may not run
 1>Ljudtestet3.obj : error LNK2028: unresolved token (0A0003DF) "public: virtual class audiere::OutputStream * __stdcall audiere::AudioDevice::openBuffer(void *,int,int,int,enum audiere::SampleFormat)" (?openBuffer@AudioDevice@audiere@@$$FUAGPAVOutputStream@2@PAXHHHW4SampleFormat@2@@Z) referenced in function "private: void __clrcall Ljudtestet3::form1::play_audio_file(int)" (?play_audio_file@form1@Ljudtestet3@@$$FA$AAMXH@Z)
 1>Ljudtestet3.obj : error LNK2019: unresolved external symbol "public: virtual class audiere::OutputStream * __stdcall audiere::AudioDevice::openBuffer(void *,int,int,int,enum audiere::SampleFormat)" (?openBuffer@AudioDevice@audiere@@$$FUAGPAVOutputStream@2@PAXHHHW4SampleFormat@2@@Z) referenced in function "private: void __clrcall Ljudtestet3::form1::play_audio_file(int)" (?play_audio_file@form1@Ljudtestet3@@$$FA$AAMXH@Z)
 1>D:\programmering\Visual C++ Express\Ljudtestet3\Debug\Ljudtestet3.exe : fatal error LNK1120: 2 unresolved externals
 1>Build log was saved at "file://d:\programmering\Visual C++ Express\Ljudtestet3\Ljudtestet3\Debug\BuildLog.htm"
 1>Ljudtestet3 - 3 error(s), 9 warning(s)
 ========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========

I have googled the errors but I haven't find a solution. I have included the lib-files, so that is not the reason for the problem. I had some other linking errors that got resolved when I included the lib-files.

Here is what I want to do with the following code:
I want to mix two wav.files, one of them containing noise.
In order to do that I want the samples of both of the files placed in different buffers. After that I add them together into one of the buffers. After that I want to play the content of the buffer. As you notice above I get problems with the OutputStream.

(I also will implement so that the noise level will be increased/decreased depending on user input. I will possibly also increase/decrease the volume of the other sound file before I mix it.)

If you either solve the linking issue above, or provide me another solution with the same functionality that I can use in a commercial product (If you provide me another solution I can  write your name and what you contributed with in a document that I attach with the application), I am thankful!
 
Thanks in advance!

Anders Branderud
http://bloganders.blogspot.com
#include "audiere.h"
      #include "sndfile.h"
  
  audiere::OutputStream* output_stream2;
  
  //Alot of other code that you don't need to see to help with this problem..

  //Open file, get information about it and then close it.
  SNDFILE* file;
  SF_INFO file_info; //Accessible file information.
  file = sf_open ("ljudfiler/HF01.wav", SFM_READ, &file_info);
 
  if (! file)
    this->angra_message_textbox->Text="Error when using sf_open;file1";
  else 
    {
    file_noise_sample_rate = file_info.samplerate;
    file_noise_channels = file_info.channels;
    file_noise_number_of_frames = file_info.frames;
    sf_close (file);
    //Todo: Error handling.
    } 

  //Open file2, get information about it and then close it.
  SNDFILE* file2; //internal information on file.
  SF_INFO file_info2; //Accessible file information.
  file2 = sf_open ("ljudfiler/noise/cocktail_noise.wav", SFM_READ, &file_info2);
  
  if (!file2)
    this->angra_message_textbox->Text="Error when using sf_open;file2";

  else
    {
  file_sample_rate = file_info2.samplerate;
  file_channels = file_info2.channels;
  file_number_of_frames = file_info2.frames;
  sf_close (file2);
  //Todo: Error handling.
    }

  //Open files and read them into buffer.
  FILE* file_a = fopen ("ljudfiler/HF01.wav", "rb");
  long len;
  short int *buffer;

  if (! file_a)
  this->angra_message_textbox->Text="Fel när filen skulle öppnas...";
  
  else
    { 
    fseek (file_a,0, SEEK_END); //go to end..
    len = ftell (file_a); //get position at end (length)
    fseek (file_a,0,SEEK_SET); //go to beginning
    buffer = (short int*) malloc (len); //malloc buffer
    fread (buffer, len, 1, file_a); //read into buffer
    fclose (file_a);
    }

  FILE* file_b = fopen ("ljudfiler/noise/cocktail_noise.wav", "rb");
  long len2;
  short int *buffer2;
  
  if (!file_b )
  this->angra_message_textbox->Text="Fel när filen skulle öppnas...";
  
  else
    {
    fseek (file_b,0, SEEK_END); //go to end..
    len2 = ftell (file_b); //get position at end (length)
    fseek (file_b,0,SEEK_SET); //go to beginning
    buffer2 = (short int*) malloc (len2); //malloc buffer
    fread (buffer2, len2,1, file_b); //read into buffer
    fclose (file_b);
    }

  //Place in SampleBuffers to be able to mix the samples of both wav files.

  SampleBuffer* sample_buffer = CreateSampleBuffer (buffer,file_number_of_frames,file_channels,file_sample_rate,SF_S16);
  SampleBuffer* sample_buffer2 = CreateSampleBuffer (buffer2,file_noise_number_of_frames,file_noise_channels,file_noise_sample_rate,SF_S16);

  //Open a seekable sample source using the samples contained in the buffer.
  SampleSource* sample_source = sample_buffer->openStream ();
  SampleSource* sample_source2 = sample_buffer2->openStream ();

  sample_source -> read (file_number_of_frames, buffer);
  sample_source2 -> read (file_noise_number_of_frames, buffer2);

  //Now the samples are placed in a buffer and we can manipulate with the buffers.
  //Mix audio file with noise file.

  for (int i =0; i < file_number_of_frames; i++ )
    {
  buffer[i] = buffer[i]+buffer2[i];
    }

                                 //Now we want to play the resulting buffer, that contains samples of the mixed wav-files.
  SampleBuffer* sample_buffer3 = CreateSampleBuffer (buffer,file_number_of_frames,file_channels,file_sample_rate,SF_S16);
  int file_to_play_frames;
  int file_to_play_channels;
  int file_to_play_sample_rate;
  enum SampleFormat file_noise_format = SF_S16;
  AudioDevicePtr audio_device(OpenDevice());
  sample_buffer3->getFormat (file_to_play_channels, file_to_play_sample_rate, file_noise_format);
  output_stream2 = audio_device->AudioDevice::openBuffer (sample_buffer3, file_number_of_frames, file_to_play_channels,file_to_play_sample_rate,SF_S16);
 

  output_stream2->play(); //Play the content of buffer

      Sleep (20000);
  fclose (file_a);
  //Todo: Error handling.

Open in new window

AndersBranderudAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

evilrixSenior Software Engineer (Avast)Commented:
So, it seems you have an unresolved symbol... where do this live?

AudioDevice::openBuffer
0
evilrixSenior Software Engineer (Avast)Commented:
>> I have included the lib-files, so that is not the reason for the problem.
You know libraries have to be included in the correct order, right?

http://www.network-theory.co.uk/docs/gccintro/gccintro_17.html
http://www.network-theory.co.uk/docs/gccintro/gccintro_18.html
0
jkrCommented:
Is there any particular reason why you are mixing managed C++ an unmanaged libraries? I'd rather go the unmanaged way here, since these libs will be easier to deal with.
0
AndersBranderudAuthor Commented:
Thanks for your replies!

I changed the code some and I got rid of the linking problem. The problem is that it doesn't play any sound.
It is late now in Sweden and I will continue tomorrow..

For the moment I only use the Audiere-library. I removed the other library temporary to see if the error was caused by a conflict between the libraries. This was not the case.

JKR wrote: "Is there any particular reason why you are mixing managed C++ an unmanaged libraries?"
Thanks for your advice! No, there is not any particular reason.

Anders Branderud
http://bloganders.blogspot.com
int file_to_play_frames;
				 int file_to_play_channels;
				 int file_to_play_sample_rate;
				 enum SampleFormat file_noise_format = SF_S16;
				 FILE* file_a = fopen ("ljudfiler/HF01.wav", "rb");
				 long len;
				 short int *buffer;
				 long len2;
				 short int *buffer2;

				 if (! file_a)
					 this->angra_message_textbox->Text="Fel när filen skulle öppnas...";
				 
				 else
				   { 
				 
					 //fseek (file_a,0, SEEK_END); //go to end..
					 //len = ftell (file_a); //get position at end (length)
					 len=100000*44100*1;
					 //fseek (file_a,0,SEEK_SET); //go to beg.
					 
					 buffer = (short int*) malloc (len); //malloc buffer
					 fread (buffer, len, 1, file_a); //read into buffer
				   }

				 FILE* file_b = fopen ("ljudfiler/noise/cocktail_noise.wav", "rb");
				 
				 if (!file_b )
					 this->angra_message_textbox->Text="Fel när filen skulle öppnas...";
				 
				 else
				   {
					 //fseek (file_b,0, SEEK_END); //go to end..
					 //len2 = ftell (file_b); //get position at end (length)
					 len2=100000*44100*1;
					 //fseek (file_b,0,SEEK_SET); //go to beg.
					 buffer2 = (short int*) malloc (len2); //malloc buffer
					 fread (buffer2,len2 ,1, file_b); //read into buffer
					 
					 }

                 SampleBuffer* sample_buffer = CreateSampleBuffer (buffer,100000,1,44100,SF_S16);
				 SampleBuffer* sample_buffer2 = CreateSampleBuffer (buffer2,100000,1,44100,SF_S16);

				 //Open a seekable sample source using the samples contained in the buffer.
				 SampleSource* sample_source = sample_buffer->openStream ();
				 SampleSource* sample_source2 = sample_buffer2->openStream();


				 //Now the samples are placed in a buffer and we can manipulate with buffers.
				 for (int i =0; i < file_number_of_frames; i++ )
				   {
					 buffer[i] = buffer[i]+buffer2[i];
				   }

				 SampleBuffer* sample_buffer3 = CreateSampleBuffer (buffer,100000,1,44100,SF_S16);
				 SampleSource* sample_source3 =sample_buffer3->openStream ();
				 //AudioDevicePtr audio_device(OpenDevice());
				 AudioDevice* dev;
				 dev = OpenDevice (0, "buffer=10000, rate=44100");
				 
				 if (dev == 0)
					 this->angra_message_textbox->Text="Error in opening device.";
				 else
					 this->angra_message_textbox->Text="No Error in opening device.";

				 Sleep (3000);
				 SampleSourcePtr sample_device_ptr(sample_source3);
				 int nr_of_channels =1;
				 int sample_rate2 =44100;
				 
				 sample_buffer3->getFormat ((int&)nr_of_channels,(int&)sample_rate2,file_noise_format);
				 output_stream2 = new OutputStreamPtr (OpenSound(dev,(const SampleSourcePtr&)sample_device_ptr,true));
				 
				 Sleep (20000);
				 
				 
				 //Just play the audio file.....

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Development

From novice to tech pro — start learning today.