- added a new check to faction validator to report on sound files with a bitrate > 200K
This commit is contained in:
parent
5d96e8f3ab
commit
c71480739b
|
@ -167,9 +167,37 @@ FactionType::~FactionType(){
|
||||||
std::vector<std::string> FactionType::validateFactionType() {
|
std::vector<std::string> FactionType::validateFactionType() {
|
||||||
std::vector<std::string> results;
|
std::vector<std::string> results;
|
||||||
|
|
||||||
|
const uint32 MAX_BITRATE_WARNING = 200000;
|
||||||
|
StrSound *factionMusic = getMusic();
|
||||||
|
if(factionMusic != NULL && factionMusic->getInfo()->getBitRate() > MAX_BITRATE_WARNING) {
|
||||||
|
char szBuf[4096]="";
|
||||||
|
sprintf(szBuf,"The Faction [%s] has the music [%s]\nwhich has a bitrate of [%u] which may cause some sound drivers to crash, please use a bitrate of %d or less!",this->getName().c_str(),factionMusic->getFileName().c_str(),factionMusic->getInfo()->getBitRate(),MAX_BITRATE_WARNING);
|
||||||
|
results.push_back(szBuf);
|
||||||
|
}
|
||||||
|
|
||||||
for(int i=0; i<unitTypes.size(); ++i){
|
for(int i=0; i<unitTypes.size(); ++i){
|
||||||
UnitType &unitType = unitTypes[i];
|
UnitType &unitType = unitTypes[i];
|
||||||
|
|
||||||
|
for(int i = 0; i < unitType.getSelectionSounds().getSounds().size(); ++i) {
|
||||||
|
StaticSound *sound = unitType.getSelectionSounds().getSounds()[i];
|
||||||
|
if(sound != NULL && sound->getInfo()->getBitRate() > MAX_BITRATE_WARNING) {
|
||||||
|
char szBuf[4096]="";
|
||||||
|
sprintf(szBuf,"The Unit [%s] in Faction [%s] has the sound [%s]\nwhich has a bitrate of [%u] which may cause some sound drivers to crash, please use a bitrate of %d or less!",unitType.getName().c_str(),this->getName().c_str(),sound->getFileName().c_str(),sound->getInfo()->getBitRate(),MAX_BITRATE_WARNING);
|
||||||
|
results.push_back(szBuf);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for(int i = 0; i < unitType.getCommandSounds().getSounds().size(); ++i) {
|
||||||
|
StaticSound *sound = unitType.getCommandSounds().getSounds()[i];
|
||||||
|
if(sound != NULL && sound->getInfo()->getBitRate() > MAX_BITRATE_WARNING) {
|
||||||
|
char szBuf[4096]="";
|
||||||
|
sprintf(szBuf,"The Unit [%s] in Faction [%s] has the sound [%s]\nwhich has a bitrate of [%u] which may cause some sound drivers to crash, please use a bitrate of %d or less!",unitType.getName().c_str(),this->getName().c_str(),sound->getFileName().c_str(),sound->getInfo()->getBitRate(),MAX_BITRATE_WARNING);
|
||||||
|
results.push_back(szBuf);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//const SoundContainer & getCommandSounds() const { return commandSounds; }
|
||||||
|
|
||||||
|
|
||||||
for(int j = 0; j < unitType.getCommandTypeCount(); ++j) {
|
for(int j = 0; j < unitType.getCommandTypeCount(); ++j) {
|
||||||
const CommandType *cmdType = unitType.getCommandType(j);
|
const CommandType *cmdType = unitType.getCommandType(j);
|
||||||
if(cmdType != NULL) {
|
if(cmdType != NULL) {
|
||||||
|
|
|
@ -174,6 +174,9 @@ public:
|
||||||
StaticSound *getSelectionSound() const {return selectionSounds.getRandSound();}
|
StaticSound *getSelectionSound() const {return selectionSounds.getRandSound();}
|
||||||
StaticSound *getCommandSound() const {return commandSounds.getRandSound();}
|
StaticSound *getCommandSound() const {return commandSounds.getRandSound();}
|
||||||
|
|
||||||
|
const SoundContainer & getSelectionSounds() const { return selectionSounds; }
|
||||||
|
const SoundContainer & getCommandSounds() const { return commandSounds; }
|
||||||
|
|
||||||
int getStore(const ResourceType *rt) const;
|
int getStore(const ResourceType *rt) const;
|
||||||
const SkillType *getSkillType(const string &skillName, SkillClass skillClass) const;
|
const SkillType *getSkillType(const string &skillName, SkillClass skillClass) const;
|
||||||
const SkillType *getFirstStOfClass(SkillClass skillClass) const;
|
const SkillType *getFirstStOfClass(SkillClass skillClass) const;
|
||||||
|
|
|
@ -31,6 +31,7 @@ private:
|
||||||
uint32 samplesPerSecond;
|
uint32 samplesPerSecond;
|
||||||
uint32 bitsPerSample;
|
uint32 bitsPerSample;
|
||||||
uint32 size;
|
uint32 size;
|
||||||
|
uint32 bitRate;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SoundInfo();
|
SoundInfo();
|
||||||
|
@ -40,11 +41,13 @@ public:
|
||||||
uint32 getSamplesPerSecond() const {return samplesPerSecond;}
|
uint32 getSamplesPerSecond() const {return samplesPerSecond;}
|
||||||
uint32 getBitsPerSample() const {return bitsPerSample;}
|
uint32 getBitsPerSample() const {return bitsPerSample;}
|
||||||
uint32 getSize() const {return size;}
|
uint32 getSize() const {return size;}
|
||||||
|
uint32 getBitRate() const {return bitRate;}
|
||||||
|
|
||||||
void setChannels(uint32 channels) {this->channels= channels;}
|
void setChannels(uint32 channels) {this->channels= channels;}
|
||||||
void setsamplesPerSecond(uint32 samplesPerSecond) {this->samplesPerSecond= samplesPerSecond;}
|
void setsamplesPerSecond(uint32 samplesPerSecond) {this->samplesPerSecond= samplesPerSecond;}
|
||||||
void setBitsPerSample(uint32 bitsPerSample) {this->bitsPerSample= bitsPerSample;}
|
void setBitsPerSample(uint32 bitsPerSample) {this->bitsPerSample= bitsPerSample;}
|
||||||
void setSize(uint32 size) {this->size= size;}
|
void setSize(uint32 size) {this->size= size;}
|
||||||
|
void setBitRate(uint32 value) {this->bitRate = value;}
|
||||||
};
|
};
|
||||||
|
|
||||||
// =====================================================
|
// =====================================================
|
||||||
|
|
|
@ -26,6 +26,7 @@ SoundInfo::SoundInfo(){
|
||||||
samplesPerSecond= 0;
|
samplesPerSecond= 0;
|
||||||
bitsPerSample= 0;
|
bitsPerSample= 0;
|
||||||
size= 0;
|
size= 0;
|
||||||
|
bitRate=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// =====================================================
|
// =====================================================
|
||||||
|
|
|
@ -91,6 +91,8 @@ void WavSoundFileLoader::open(const string &path, SoundInfo *soundInfo){
|
||||||
f.read((char*) &size16, 2);
|
f.read((char*) &size16, 2);
|
||||||
soundInfo->setBitsPerSample(size16);
|
soundInfo->setBitsPerSample(size16);
|
||||||
|
|
||||||
|
soundInfo->setBitRate(soundInfo->getSamplesPerSecond() * soundInfo->getChannels() * soundInfo->getBitsPerSample() / 8);
|
||||||
|
|
||||||
if (soundInfo->getBitsPerSample() != 8 && soundInfo->getBitsPerSample()!=16){
|
if (soundInfo->getBitsPerSample() != 8 && soundInfo->getBitsPerSample()!=16){
|
||||||
throw runtime_error("Bits per sample must be 8 or 16: " + path);
|
throw runtime_error("Bits per sample must be 8 or 16: " + path);
|
||||||
}
|
}
|
||||||
|
@ -167,6 +169,7 @@ void OggSoundFileLoader::open(const string &path, SoundInfo *soundInfo){
|
||||||
soundInfo->setsamplesPerSecond(vi->rate);
|
soundInfo->setsamplesPerSecond(vi->rate);
|
||||||
soundInfo->setBitsPerSample(16);
|
soundInfo->setBitsPerSample(16);
|
||||||
soundInfo->setSize(samples * 2 * vi->channels);
|
soundInfo->setSize(samples * 2 * vi->channels);
|
||||||
|
soundInfo->setBitRate(vi->bitrate_nominal);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32 OggSoundFileLoader::read(int8 *samples, uint32 size){
|
uint32 OggSoundFileLoader::read(int8 *samples, uint32 size){
|
||||||
|
|
Loading…
Reference in New Issue