How can I get the WAV data from the whole song?

Austech
  • How can I get the WAV data from the whole song? Austech

    I'm using FMOD (with C++ syntax, not C) and I'm having trouble getting the wave data of a whole sound file.

    Channel::GetWave() only gets the wave data of the area on which it is currently playing.

    The documentation says:

    Do not use this function to try and display the whole waveform of the sound, as this is more of a 'snapshot' of the current waveform at the time it is called, and could return the same data if it is called very quickly in succession.

    See the DSP API to capture a continual stream of wave data as it plays, or see Sound::lock / Sound::unlock if you want to simply display the waveform of a sound.

    Unfortunately, the Sound::lock and unlock functions are pretty confusing, at least to me.

    Lock:

    FMOD_RESULT Sound::lock(
      unsigned int  offset, 
      unsigned int  length, 
      void **  ptr1, 
      void **  ptr2, 
      unsigned int *  len1, 
      unsigned int *  len2
    );
    

    offset

    Offset in bytes to the position you want to lock in the sample buffer.

    length

    Number of bytes you want to lock in the sample buffer.

    ptr1

    Address of a pointer that will point to the first part of the locked data.

    ptr2

    Address of a pointer that will point to the second part of the locked data. This will be null if the data locked hasn't wrapped at the end of the buffer.

    len1

    Length of data in bytes that was locked for ptr1

    len2

    Length of data in bytes that was locked for ptr2. This will be 0 if the data locked hasn't wrapped at the end of the buffer.

    Unlock:

    FMOD_RESULT Sound::unlock(
      void *  ptr1, 
      void *  ptr2, 
      unsigned int  len1, 
      unsigned int  len2
    );
    

    ptr1

    Pointer to the 1st locked portion of sample data, from Sound::lock.

    ptr2

    Pointer to the 2nd locked portion of sample data, from Sound::lock.

    len1

    Length of data in bytes that was locked for ptr1

    len2

    Length of data in bytes that was locked for ptr2. This will be 0 if the data locked hasn't wrapped at the end of the buffer.

    But as I said, my goal is to be able to get the wave data of the beginning of a song to the end.

  • The way I read it, the last four parameters are output parameters. So you basically pass in 4 variables of the requested type and after the function has finished, these are populated with the data you need.

    What you do is something along these lines:

    void  *pointer1;
    void  *pointer2;
    unsigned int length1;
    unsigned int length2;
    
    // lock the buffer
    mySound->lock(0, lengthOfYourSoundInBytes, &pointer1, &pointer2, &length1, &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
    mySound->unlock(pointer1, pointer2, length1, length2);
    

    From my understanding you won't need pointer2 and length2 at all. The only thing you'll have to figure out is the length of your sound data (see lengthOfYourSoundInBytes above). Once you locked the buffer, you'll get a pointer to the data and you can do whatever you want with it.

Tags
c++ fmod
Related questions and answers
  • (); }; #endif If I call Init() from game.cpp, the code works fine, if I call cube->init(), just as this function is entered (not when the other one is left), the device pointer suddenly has an address..._WRITE; bd.MiscFlags = 0; device->CreateBuffer(&bd, NULL, &pBuffer); void* pVoid; // the void pointer pBuffer->Map(D3D10_MAP_WRITE_DISCARD, 0, &pVoid); // map the vertex buffer...) * 8; bd.BindFlags = D3D10_BIND_VERTEX_BUFFER; bd.CPUAccessFlags = D3D10_CPU_ACCESS_WRITE; bd.MiscFlags = 0; device->CreateBuffer(&bd, NULL, &pBuffer); void* pVoid; // the void pointer

  • wrong in my frame buffer set up code, or elsewhere. But I can't see what. The FBO is set up through the following function: unsigned int fbo_id; unsigned int depth_buffer; int m_FBOWidth, m_FBOHeight; unsigned int m_TextureID; void initFBO() { m_FBOWidth = screen_width; m_FBOHeight = screen_height; glGenRenderbuffers(1, &depth_buffer); glBindRenderbuffer(GL_RENDERBUFFER...;MVP[0]); } glBindVertexArray(vaoID); glDrawElements(GL_TRIANGLES, sizeof(cube.polygon)/sizeof(cube.polygon[0]), GL_UNSIGNED_INT, 0); } void drawStaticBox() { Matrix4 M(1

  • object from an array of CustomVertex objects. This array is said to be interleaved. It renders successfully with the following code: void VertexBufferObject::Draw() { if( ! m_bInitialized..._TRIANGLES, m_nNumIndices, GL_UNSIGNED_INT, ((char*)NULL + 0) ); glDisableClientState( GL_VERTEX_ARRAY ); glDisableClientState( GL_TEXTURE_COORD_ARRAY ); glDisableClientState( GL_NORMAL_ARRAY ); glDisableClientState( GL_COLOR_ARRAY ); glBindBuffer( GL_ARRAY_BUFFER, 0 ); glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, 0 ); } Back to the Vertex Array Object though. My code for creating the Vertex

  • ? Something unnecessary that maybe you guys could spot? Both MD2 and 3DS loader have an InitToon() function called upon creation to load the shader initToon(){ int i...); // Set The Color Of The Model ( NEW ) // ORIGINAL DRAWING CODE //Draw the model as an interpolation between the two frames glBegin(GL_TRIANGLES); for(int i = 0; i... NEHE'S TUT glBegin (GL_TRIANGLES); // Tell OpenGL What We Want To Draw for(int i = 0; i < numTriangles; i++) { MD2Triangle* triangle

  • destroy_shield() {shield--; if(shield<0) alive= false;} string get_name() {return name;}; string set_name(string aName) {name = aName;}; int* get_location(){return location;}; void... from it. As an added touch i have made it so after you collide while traveling down the randomly generated map (or rather as the walls move uppward while your character stays put) the X chars you've...}; // for the old/new screen command // Some nCurses setup int r = 0, c = 0; // current row and column (upper-left is (0,0)) const int nrows = 56, // number of rows in window ncols = 79

  • new Object(); in the bottom part of the code sample. static BaseObject * CreateObjectFunc() { return new Object(); } How and where to delete the pointers? I wrote bool ReleaseClassType(). Despite the factory works well, ReleaseClassType() does not fix memory leaks. bool ReleaseClassTypes() { unsigned int nRecordCount = vFactories.size(); for (unsigned int nLoop = 0; nLoop <...() { unsigned int nRecordCount = vFactories.size(); for (unsigned int nLoop = 0; nLoop < nRecordCount; nLoop++ ) { // if the object exists in the container and is valid, then render

  • don't want to find out in the end that I have to rewrite everything again, as a lot of other objects will be working with these data. Sorry if it's a too subjective matter, but I need some insight. I'm... them to be attached to the node in most cases, even if I allow setting global lights to the scene. @Nicol: Yes that's what I'm trying to figure out. You can see the code doesn't rely on any hardware... animation I would end up storing a lot of data that I don't really need, even if I'm indexing node and frame data when saving and then store the hierarchy with the indices to the actual data. I don't

  • ;at(index)->Kill(); } } } void DrawBullets(BITMAP* buffer, BITMAP* sprite) { for(unsigned int index = 0; index < bullets->size(); index++) { if (bullets->at(index...(); missile->Init(true, s->X, s->Y); bullets->push_back(missile); } } void CleanUp() { for(unsigned int index = 0; index < bullets->size(); index++) { if (bullets->at(index)->Alive == false) { bullets->erase(bullets->begin() + index); } } } void UpdateBullets() { for(unsigned int index = 0; index <

  • _Commands, m_MD2Header.num_glcommands * sizeof(int)); // Read all the data. for(int i = 0; i < m_MD2Header.num_frames; ++i) { md2_frame_t* Frame = (md2_frame_t*)&Buffer...I'm trying to load MD2 models (stolen from Cube) and my loader seems to be loading the models fine, but I can't say the same for the drawing of the model. Here's my code: typedef float vec3_t[3...); if(!File.is_open()) { Debugging::Debugf("Unable to open the file: %s", Path.c_str()); exit(0); } // Get the filesize. File.seekg (0, std::ios::end); int Size

Data information