HSTREAM D3DCore_Impl::Stream_Load(const WCHAR *filename, DWORD size) { if(m_bSilent) return 0; void *data; DWORD _size; CStreamList *stmItem; if(m_pADevice) { if(size) { data=(void *)filename; _size=size; } else { data=File_Load(filename, &_size); if(!data) return 0; } FilePtr pf = CreateMemoryFile(data, _size); SampleSourcePtr source = OpenSampleSource(pf); if (!source) { System_Log(L"[AUDIERE - ERROR] %s: Can't load sample source", filename); return 0; } LoopPointSourcePtr loop_source = CreateLoopPointSource(source); if (loop_source) { source = loop_source.get(); } OutputStream* stream = OpenSound( m_pADevice, source, true); if (!stream) { System_Log(L"[AUDIERE - ERROR] %s: Can't load stream", filename); if(!size) File_Free(data); return 0; } stream->ref(); if(!size) { stmItem=new CStreamList; stmItem->hstream=(HSTREAM)stream; stmItem->data=data; stmItem->next=streams; streams=stmItem; } return (HSTREAM)stream; } else return 0; }
HCHANNEL D3DCore_Impl::Effect_Play(HEFFECT eff) { if(m_pADevice && eff != 0) { SampleSource* SSource = (SampleSource*)eff; OutputStream* OStream = OpenSound( m_pADevice, SSource, false ); OStream->setVolume( m_VolFX ); OStream->play(); OStream->ref(); // EffectChannelList.insert((HCHANNEL)OStream); Channel* chn = new Channel; chn->Handler = (HCHANNEL)OStream; chn->Type = CT_EFFECT; chn->next = channels; channels = chn; return (HCHANNEL)OStream; } else return 0; }
HCHANNEL D3DCore_Impl::Effect_PlayEx(HEFFECT eff, int volume, int pan, float pitch, bool loop) { if(m_pADevice && eff != 0) { SampleSource* SSource = (SampleSource*)eff; OutputStream* OStream = OpenSound( m_pADevice, SSource, false ); OStream->setVolume( m_VolFX * (volume/100.0f) ); OStream->setPan( pan/100.0f ); OStream->setPitchShift( pitch ); OStream->setRepeat( loop ); OStream->play(); OStream->ref(); // EffectChannelList.insert((HCHANNEL)OStream); Channel* chn = new Channel; chn->Handler = (HCHANNEL)OStream; chn->Type = CT_EFFECT; chn->next = channels; channels = chn; return (HCHANNEL)OStream; } else return 0; }