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

SoundCapacity.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  * サウンド能力実装
00022  * @author Junpee
00023  */
00024 
00025 #include "LampBasic.h"
00026 #include "Sound/System/SoundCapacity.h"
00027 #include "Sound/System/SoundDefinition.h"
00028 
00029 namespace Lamp{
00030 
00031 //------------------------------------------------------------------------------
00032 // コンストラクタ
00033 SoundCapacity::SoundCapacity() : directSound_(NULL){
00034 }
00035 //------------------------------------------------------------------------------
00036 // デストラクタ
00037 SoundCapacity::~SoundCapacity(){
00038 }
00039 //------------------------------------------------------------------------------
00040 // 初期化
00041 bool SoundCapacity::initialize(DirectSound* directSound){
00042     directSound_ = directSound;
00043     if(!refresh()){ return false; }
00044     // 能力に適合しなくてもDirectSoundが対応してくれる?
00045 //  if(!checkCapacity()){ return false; }
00046     return true;
00047 }
00048 //------------------------------------------------------------------------------
00049 // 更新
00050 bool SoundCapacity::refresh(){
00051     capacity_.dwSize = sizeof(DSCAPS);
00052     if(DirectXFailed(directSound_->GetCaps(&capacity_))){
00053         ErrorOut("SoundCapacity::refresh() サウンド能力の取得に失敗しました");
00054         return false;
00055     }
00056     return true;
00057 }
00058 //------------------------------------------------------------------------------
00059 // 能力チェック
00060 bool SoundCapacity::checkCapacity(){
00061     // プライマリバッファのチェック
00062     if((SoundDefinition::primaryBufferBit == 8) &&
00063         (!isSupported8bitPrimaryBuffer())){
00064         ErrorOut("SoundCapacity::checkCapacity() "
00065             "8bitプライマリバッファがサポートされていません");
00066         return false;
00067     }
00068     if((SoundDefinition::primaryBufferBit == 16) &&
00069         (!isSupported16bitPrimaryBuffer())){
00070         ErrorOut("SoundCapacity::checkCapacity() "
00071             "16bitプライマリバッファがサポートされていません");
00072         return false;
00073     }
00074     if(SoundDefinition::primaryBufferStereo){
00075         if(!isSupportedStereoPrimaryBuffer()){
00076             ErrorOut("SoundCapacity::checkCapacity() "
00077                 "ステレオプライマリバッファがサポートされていません");
00078             return false;
00079         }
00080     }else{
00081         if(!isSupportedMonauralPrimaryBuffer()){
00082             ErrorOut("SoundCapacity::checkCapacity() "
00083                 "モノラルプライマリバッファがサポートされていません");
00084             return false;
00085         }
00086     }
00087     // セカンダリバッファのチェック
00088     if((SoundDefinition::secondaryBufferBit == 8) &&
00089         (!isSupported8bitSecondaryBuffer())){
00090         ErrorOut("SoundCapacity::checkCapacity() "
00091             "8bitセカンダリバッファがサポートされていません");
00092         return false;
00093     }
00094     if((SoundDefinition::secondaryBufferBit == 16) &&
00095         (!isSupported16bitSecondaryBuffer())){
00096         ErrorOut("SoundCapacity::checkCapacity() "
00097             "16bitセカンダリバッファがサポートされていません");
00098         return false;
00099     }
00100     if(!isSupportedStereoSecondaryBuffer()){
00101         ErrorOut("SoundCapacity::checkCapacity() "
00102             "ステレオセカンダリバッファがサポートされていません");
00103         return false;
00104     }
00105     if(!isSupportedMonauralSecondaryBuffer()){
00106         ErrorOut("SoundCapacity::checkCapacity() "
00107             "モノラルセカンダリバッファがサポートされていません");
00108         return false;
00109     }
00110     if(SoundDefinition::secondaryBufferRate > getMaxSecondarySampleRate()){
00111         ErrorOut("SoundCapacity::checkCapacity() "
00112             "セカンダリバッファのサンプリングレートが大きすぎます");
00113         return false;
00114     }
00115     if(SoundDefinition::secondaryBufferRate < getMinSecondarySampleRate()){
00116         ErrorOut("SoundCapacity::checkCapacity() "
00117             "セカンダリバッファのサンプリングレートが小さすぎます");
00118         return false;
00119     }
00120     return true;
00121 }
00122 //------------------------------------------------------------------------------
00123 // 文字列への変換
00124 String SoundCapacity::toString() const{
00125     String result, temp;
00126     result += "Microsoft認定ドライバ      " +
00127         getBoolString(isCertifiedDriver()) + "\n";
00128     result += "連続的な周波数設定         " +
00129         getBoolString(isSupportedContinuousRate()) + "\n";
00130     result += "エミュレートドライバ       " +
00131         getBoolString(isEmulatedDriver()) + "\n";
00132     result += "16bitプライマリバッファ    " +
00133         getBoolString(isSupported16bitPrimaryBuffer()) + "\n";
00134     result += "8bitプライマリバッファ     " +
00135         getBoolString(isSupported8bitPrimaryBuffer()) + "\n";
00136     result += "モノラルプライマリバッファ " +
00137         getBoolString(isSupportedMonauralPrimaryBuffer()) + "\n";
00138     result += "ステレオプライマリバッファ " +
00139         getBoolString(isSupportedStereoPrimaryBuffer()) + "\n";
00140     result += "16bitセカンダリバッファ    " +
00141         getBoolString(isSupported16bitSecondaryBuffer()) + "\n";
00142     result += "8bitセカンダリバッファ     " +
00143         getBoolString(isSupported8bitSecondaryBuffer()) + "\n";
00144     result += "モノラルセカンダリバッファ " +
00145         getBoolString(isSupportedMonauralSecondaryBuffer()) + "\n";
00146     result += "ステレオセカンダリバッファ " +
00147         getBoolString(isSupportedStereoSecondaryBuffer()) + "\n";
00148 
00149     temp.format("セカンダリ最大サンプリングレート %5uHz\n",
00150         getMaxSecondarySampleRate());
00151     result += temp;
00152     temp.format("セカンダリ最小サンプリングレート %5uHz\n",
00153         getMinSecondarySampleRate());
00154     result += temp;
00155 
00156     return result;
00157 }
00158 //------------------------------------------------------------------------------
00159 } // End of namespace Lamp
00160 //------------------------------------------------------------------------------

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