/// /// オーディオリソース生成 AudioResourcePtr AudioResource::create( FilePath& filepath ///< ファイルパス ) { // 未サポート判定 T3_ASSERT_MSG(filepath.ext() == ".wav", "%s is not support. only supported .wav", filepath.filename().c_str()); // とりあえず.wavだけサポート Wav wav; wav.load(filepath); // リソース生成 AudioResourcePtr res; res.reset(T3_SYS_NEW AudioResource); res->setupBuffer(wav); res->resourceName(filepath.filename().c_str()); res->createHandle(); return res; }
int Wav_load(void * aClassPtr, const char * aFilename) { Wav * cl = (Wav *)aClassPtr; return cl->load(aFilename); }
int SampleHold::loadDir(const string& path) { ProgramState& progstate = ProgramState::instance(); if(path.size()==0) { DERROR("path empty"); return 1; } FileDir fd; bool exist = fd.read(path, false, ".wav", false, false); if(!exist) { DERROR("(E) SampleHold loadDIR(): no such dir!"); return 1; } vector<string> files; fd.getFiles(files); if(files.size()==0)return 0; for(unsigned int i=0; i<files.size(); i++) { Wav w; string str=path+files[i]; //FIXME: better errorchecking! Wav::err ret = w.load(str); //w.info(); if(ret==Wav::FILE_NOTFOUND_ERR)continue; //something went wrong but probably file does not exist... if(!w.ok()) { DERROR("something wrong happend"); continue; } WavSample* samp; if(w.isStereo()) { SampleValue* l = new SampleValue(w.makeSample(Wav::EXTRACT_LEFT)); l->setResampleRate(w.getSampleRate(), progstate.getSampleRate()); SampleValue* r = new SampleValue(w.makeSample(Wav::EXTRACT_RIGHT)); r->setResampleRate(w.getSampleRate(), progstate.getSampleRate()); samp = new WavSample(files[i], l,r); } else { SampleValue* m = new SampleValue(w.makeSample(Wav::EXTRACT_ALL)); m->setResampleRate(w.getSampleRate(), progstate.getSampleRate()); samp = new WavSample(files[i], m); } samples.push_back(samp); w.del(); } return 0; }