/*---------------------------------------------------------------------------* Project: NintendoWare File: snd_WaveSound.cpp Copyright (C)2009-2010 Nintendo Co., Ltd./HAL Laboratory, Inc. All rights reserved. These coded instructions, statements, and computer programs contain proprietary information of Nintendo of America Inc. and/or Nintendo Company Ltd., and are protected by Federal copyright law. They may not be disclosed to third parties or copied or duplicated in any form, in whole or in part, without the prior written consent of Nintendo. $Revision: 20021 $ *---------------------------------------------------------------------------*/ #include "precompiled.h" #include #include #include #include namespace nw { namespace snd { namespace internal { NW_UT_RUNTIME_TYPEINFO_DEFINITION(WaveSound,BasicSound); /* ======================================================================== member function ======================================================================== */ /*---------------------------------------------------------------------------* Name: WaveSound Description: コンストラクタ Arguments: None. Returns: None. *---------------------------------------------------------------------------*/ WaveSound::WaveSound( WaveSoundInstanceManager& manager ) : m_pManager( manager ), m_InitializeFlag(false) { } void WaveSound::Initialize() { BasicSound::Initialize(); m_pTempSpecialHandle = NULL; m_PreparedFlag = false; m_InitializeFlag = true; } /*---------------------------------------------------------------------------* Name: Shutdown Description: サウンドの終了 Arguments: None. Returns: None. *---------------------------------------------------------------------------*/ void WaveSound::Finalize() { if ( ! m_InitializeFlag ) return; m_InitializeFlag = false; BasicSound::Finalize(); m_pManager.Free( this ); } /*---------------------------------------------------------------------------* Name: Prepare Description: サウンド開始 Arguments: seqDataBase - シーケンスデータベースアドレス seqDataOffset - シーケンスデータのオフセット bank - バンクデータ Returns: None. *---------------------------------------------------------------------------*/ void WaveSound::Prepare( const void* waveSoundBase, s32 waveSoundOffset, driver::WaveSoundPlayer::StartOffsetType startOffsetType, s32 offset, const driver::WaveSoundPlayer::WaveSoundCallback* callback, u32 callbackData ) { NW_NULL_ASSERT( waveSoundBase ); NW_NULL_ASSERT( callback ); DriverCommandManager& cmdmgr = DriverCommandManager::GetInstance(); DriverCommandWaveSoundSetup* command = cmdmgr.AllocCommand(); command->id = DRIVER_COMMAND_WAVESND_SETUP; command->player = &m_WaveSoundPlayerInstance; command->waveSoundBase = waveSoundBase; command->waveSoundOffset = waveSoundOffset; command->startOffsetType = startOffsetType; command->offset = offset; command->callback = callback; command->callbackData = callbackData; cmdmgr.PushCommand(command); m_PreparedFlag = true; } /*---------------------------------------------------------------------------* Name: SetChannelPriority Description: 発音プライオリティを変更 Arguments: priority - 発音プライオリティ Returns: None. *---------------------------------------------------------------------------*/ void WaveSound::SetChannelPriority( int priority ) { NW_MINMAX_ASSERT( priority, 0, 127 ); DriverCommandManager& cmdmgr = DriverCommandManager::GetInstance(); DriverCommandWaveSoundChannelPrio* command = cmdmgr.AllocCommand(); command->id = DRIVER_COMMAND_WAVESND_CHANNELPRIO; command->player = &m_WaveSoundPlayerInstance; command->priority = priority; cmdmgr.PushCommand(command); } /*---------------------------------------------------------------------------* Name: SetReleasePriorityFix Description: リリース時のプライオリティを変化しないようにする Arguments: fix - Returns: なし *---------------------------------------------------------------------------*/ void WaveSound::SetReleasePriorityFix( bool fix ) { DriverCommandManager& cmdmgr = DriverCommandManager::GetInstance(); DriverCommandWaveSoundPrioFix* command = cmdmgr.AllocCommand(); command->id = DRIVER_COMMAND_WAVESND_PRIOFIX; command->player = &m_WaveSoundPlayerInstance; command->priorityFix = fix; cmdmgr.PushCommand(command); } /*---------------------------------------------------------------------------* Name: OnUpdatePlayerPriority Description: プレイヤープライオリティを変更 Arguments: Returns: None. *---------------------------------------------------------------------------*/ void WaveSound::OnUpdatePlayerPriority() { int priority = CalcCurrentPlayerPriority(); m_pManager.UpdatePriority( this, priority ); } bool WaveSound::IsAttachedTempSpecialHandle() { return m_pTempSpecialHandle != NULL; } void WaveSound::DetachTempSpecialHandle() { // TODO: m_pTempSpecialHandle->DetachSound(); } bool WaveSound::ReadWaveSoundDataInfo( WaveSoundDataInfo* info ) const { if ( ! IsPlayerAvailable() ) return false; return m_WaveSoundPlayerInstance.ReadWaveSoundDataInfo( info ); } long WaveSound::GetPlaySamplePosition() const { if ( ! IsPlayerAvailable() ) return 0; return m_WaveSoundPlayerInstance.GetPlaySamplePosition(); } } // namespace nw::snd::internal } // namespace nw::snd } // namespace nw