0
0

Good afternoon,

I need to know how to directly access the sound data from a file
I could not find any documentation on the data structure of FMOD::SOUND,
I’m assuming there are two ways to to access this data:

1
create sound stream
lock it in memory
manipulate data
unlock

2
load the file into a buffer
create sound from buffer
free buffer
manipulate data

In both methods I’m having a problem accessing sound data directly.
In Method 1, when trying to view the value of pointer1 using pointer1[0…] I get
[b:3rbs06gd]
pointer1[0] CXX0034: Error: types incompatible with operator[/b:3rbs06gd]

The code for method 1 (which I pulled together from various forum posts) is posted at the end/

In Method 2, which is the "\FMOD Programmers API Windows\examples\loadfrommemory" example
I’m trying to access "buff[0…]" and I get similar issue where the variable doesn’t exist.

Is this the correct way of accessing sound data? Am I missing something?
How can a pointer to the sound data can be of type "[b:3rbs06gd]void[/b:3rbs06gd] *pointer1;" doesn’t that defy the meaning of a pointer?
Additionally I looked around and other examples use "void * *pointer1;" which doesn’t seem to work for me

If you can explain why I can’t get sound data from a file or point me to an example or a tutorial which explains how to do it properly,
I am a C# user, so please take care to explain carefully so I won’t ask too many questions. I understand that there is a C# extension, but I will not be using it, because my application will eventually be in linux.

Thank you very much,
-Dmitry

[code:3rbs06gd]

include "fmod.h"

include "fmod.hpp"

include "fmod_errors.h"

include <windows.h>

include <conio.h>

include <iostream>

include <cstdlib>

include <fmod.h>

include <fmod.hpp>

include <windows.h>

using namespace std;
bool keyDown(int key)
{
if(GetAsyncKeyState(key) == 0) //key is not pressed, return false
return false;
else //key IS pressed, return true
return true;
}
int main(){
bool quit = false;
//declare variable for FMOD system object
FMOD::System* system;
//allocate memory for the FMOD system object
FMOD_RESULT result = FMOD::System_Create(&system);
//initialize the FMOD system object
system->init(32, FMOD_INIT_NORMAL, NULL);
//declare variable for the sound object
FMOD::Sound* sound;
//created sound object and specify the sound
result = system->createSound("MLFY.mp3",
FMOD_LOOP_NORMAL,NULL, &sound);
// play sound – 1st parameter can be combined flags (| separator)
FMOD::Channel* channel = 0;
bool pauseSound = false;

//Addition to the code//
void  *pointer1;
void  *pointer2;
unsigned int length1;
unsigned int length2;

// lock the buffer
sound-&gt;lock(0, 60, &amp;pointer1, &amp;pointer2, &amp;length1, &amp;length2);

// when we're here, pointer1, pointer2, length1 and length2 will be populated.
// do something with the sound data found in pointer1.
// the sound data will have a length stored in length1

// unlock the buffer once you're done

int k = 100;

while(!quit){
    //start sound
    if(keyDown('1') == true){
        channel-&gt;isPlaying(&amp;pauseSound);
        if(pauseSound == false)
            result = system-&gt;playSound(FMOD_CHANNEL_FREE, sound,
            false, &amp;channel);
    }
    //stop sound
    if(keyDown('2') == true){
        channel-&gt;stop();
    }
    //pause sound
    if(keyDown('3') == true){
        channel-&gt;setPaused(true);
    }
    //unpause sound
    if(keyDown('4') == true){
        channel-&gt;setPaused(false);
    }
    if(keyDown(VK_ESCAPE))
        quit = true;
    system-&gt;update();
}

sound-&gt;unlock(pointer1, pointer2, length1, length2);


// release resources
result = sound-&gt;release();
result = system-&gt;close();
result = system-&gt;release();
return 0;

}

[/code:3rbs06gd]

  • You must to post comments
0
0

I was wondering if anybody had a chance to take a look at this post

  • You must to post comments
0
0

if you know the type of the sound (ie 16bit pcm) then you just have to cast your void * pointer to a signed short * pointer

then you can use signed short *sptr = (signed short *)ptr; and use sptr[0], sptr[1] etc.

  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.