Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Namespace Members | Compound Members | File Members

StreamSound3D.cpp

Go to the documentation of this file.
00001 //------------------------------------------------------------------------------
00002 // Lamp : Open source game middleware
00003 // Copyright (C) 2004  Junpei Ohtani ( Email : junpee@users.sourceforge.jp )
00004 //
00005 // This library is free software; you can redistribute it and/or
00006 // modify it under the terms of the GNU Lesser General Public
00007 // License as published by the Free Software Foundation; either
00008 // version 2.1 of the License, or (at your option) any later version.
00009 //
00010 // This library is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013 // Lesser General Public License for more details.
00014 //
00015 // You should have received a copy of the GNU Lesser General Public
00016 // License along with this library; if not, write to the Free Software
00017 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018 //------------------------------------------------------------------------------
00019 
00020 /** @file
00021  * ストリーム3Dサウンド実装
00022  * @author Junpee
00023  */
00024 
00025 #include "LampBasic.h"
00026 #include "Sound/3D/StreamSound3D.h"
00027 #include "Sound/Reader/SoundReader.h"
00028 #include "Sound/Utility/StreamPlayer.h"
00029 #include "Sound/System/LampSound.h"
00030 #include "Sound/System/SoundManager.h"
00031 
00032 namespace Lamp{
00033 
00034 //------------------------------------------------------------------------------
00035 // コンストラクタ
00036 StreamSound3D::StreamSound3D(DirectSoundBuffer* soundBuffer) :
00037     Sound3D(soundBuffer), soundReader_(NULL), streamPlayer_(NULL){
00038 }
00039 //------------------------------------------------------------------------------
00040 // デストラクタ
00041 StreamSound3D::~StreamSound3D(){
00042     SafeDelete(streamPlayer_);
00043     SafeDelete(soundReader_);
00044 }
00045 //------------------------------------------------------------------------------
00046 // サウンドリーダの設定
00047 void StreamSound3D::setSoundReader(SoundReader* soundReader){
00048     Assert(soundReader_ == NULL);
00049     soundReader_ = soundReader;
00050     Assert(soundReader_ != NULL);
00051     // 最低バッファ長のサウンドを必要とする
00052     Assert(getSize() >= (getBufferSize() / 2));
00053     // ストリームプレーヤ初期化
00054     streamPlayer_ = new StreamPlayer();
00055     streamPlayer_->initialize(this, soundReader_);
00056 }
00057 //------------------------------------------------------------------------------
00058 // サイズの取得
00059 u_int StreamSound3D::getSize() const{
00060     Assert(soundReader_ != NULL);
00061     return soundReader_->getSize();
00062 }
00063 //------------------------------------------------------------------------------
00064 // 再生
00065 //------------------------------------------------------------------------------
00066 // 停止
00067 void StreamSound3D::stop(){
00068     SoundBuffer::stop();
00069     // バッファの開始位置をずらしてストリームプレーヤをリセットする
00070     SoundBuffer::setCursor(0);
00071     streamPlayer_->reset();
00072 }
00073 //------------------------------------------------------------------------------
00074 // 再生位置
00075 //------------------------------------------------------------------------------
00076 // 再生位置設定
00077 void StreamSound3D::setCursor(u_int cursor){
00078     Assert(streamPlayer_ != NULL);
00079     streamPlayer_->setCursor(cursor);
00080 }
00081 //------------------------------------------------------------------------------
00082 // 再生位置取得
00083 u_int StreamSound3D::getCursor() const{
00084     Assert(streamPlayer_ != NULL);
00085     return streamPlayer_->getCursor();
00086 }
00087 //------------------------------------------------------------------------------
00088 // ループ
00089 //------------------------------------------------------------------------------
00090 // ループ位置の設定
00091 void StreamSound3D::setLoopCursor(u_int loopCursor){
00092     Assert(streamPlayer_ != NULL);
00093     streamPlayer_->setLoopCursor(loopCursor);
00094 }
00095 //------------------------------------------------------------------------------
00096 // ループ位置の取得
00097 u_int StreamSound3D::getLoopCursor() const{
00098     Assert(streamPlayer_ != NULL);
00099     return streamPlayer_->getLoopCursor();
00100 }
00101 //------------------------------------------------------------------------------
00102 } // End of namespace Lamp
00103 //------------------------------------------------------------------------------

Generated on Wed Mar 16 10:29:36 2005 for Lamp by doxygen 1.3.2