Skip to main content
gamedev.net
🔒 Locked

DirectAudio Problems

Started by gnolo 0 replies 500+ views
Original Post
gnolo
gnolo
Hi, I''m coding an audio system using DirectMusic 8. I want a list of channels and a list of samples. Each sample can be played into any channel (each new sample stops the previous sample). Then I want to be able to stop a channel without affect other channels (where the same sample could being in play) So I decided to use a list of IDirectMusicPerformance8 as channels and a list of IDirectMusicSegment8 as sample.
  

/**
 * the single channel
 */
typedef struct tagChannel 
{
    IDirectMusicPerformance8 *perf;  
    IDirectMusicAudioPath8   *path;  
    IDirectSoundBuffer8      *buff;  
} Channel;

/**
 * list of channels
 */
static Channel *channels;
/**
 * list of samples
 */
static IDirectMusicSegment8 **samples;

  
Then I create my two list and I''inizialize every single channel in a for loop using the following function
  
static int initChannel(Channel *c)
{
    //creo l''oggetto performance

    if(FAILED(CoCreateInstance(&CLSID_DirectMusicPerformance, 
    NULL,
    CLSCTX_INPROC, 
    &IID_IDirectMusicPerformance8, 
    (void **)&c->perf)))
        return 0;

    if(FAILED(c->perf->lpVtbl->InitAudio(c->perf,
    NULL, //IDirectMusic

    NULL, //IDirectSound

    NULL,
    DMUS_APATH_DYNAMIC_STEREO,
    64,
    DMUS_AUDIOF_ALL,
    NULL)))
        return 0;
    
    //adesso creo l''audio path su cui suonare

    if(FAILED(c->perf->lpVtbl->CreateStandardAudioPath(
    c->perf,
    DMUS_APATH_DYNAMIC_STEREO,
    64,
    TRUE,
    &c->path)))
        return 0;

    //adesso recupero il SoundBuffer per gli effetti

    if(FAILED(c->path->lpVtbl->GetObjectInPath(c->path, 
    DMUS_PCHANNEL_ALL, DMUS_PATH_BUFFER, 0, &GUID_NULL, 0, 
    &IID_IDirectSoundBuffer8, (void **)&c->buff)))
        return 0;
    
    return 1;
}    
  
Then when I load a sample (using IDirectMusicLoader8) into IDirectMusicSegment8 I download it in every channel. The problem is that only the first channel created play (I use a log file and no error is thrown when I play Segment in other channels, but there isn''t sound) Could someone help me, please?! Sorry for my English but I''m Italian gnolo
gnolo

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.