--- Vago/trunk/Vago/soundWizard/soundpagefinal.cpp 2016/09/16 22:51:26 1047 +++ s10k/Vago/soundWizard/soundpagefinal.cpp 2017/12/30 13:43:28 1092 @@ -45,8 +45,10 @@ void SoundPageFinal::startProcessing(){ // Sample files names QString ambFile="OSBDsample_file.amb.xml"; QString grpFile="OSBDsample_file.grp.xml"; + QString impFile="OSBDsample_file.imp.xml"; QString ambFileLocation=GlobalVars::VagoTemporaryDir+"/"+ambFile; QString grpFileLocation=GlobalVars::VagoTemporaryDir+"/"+grpFile; + QString impFileLocation=GlobalVars::VagoTemporaryDir+"/"+impFile; // Page 2 variables QString outputFolder; @@ -68,6 +70,18 @@ void SoundPageFinal::startProcessing(){ bool preventRepeat=false; bool stereo22=false, mono22=false, mono44Pc=false; + // Page 5 variables + QString minVolumeDistanceImp, maxVolumeDistanceImp, minAngleImp, + maxAngleImp, minAttenuationImp, impactVelocityImp, + minOcclusionImp, priorityImp; + bool priorityLowImp = false, priorityNormalImp = false, + priorityHighImp = false, priorityHighestImp = false; + + // Create temp folder if it doesn't exist + if(!QDir(GlobalVars::VagoTemporaryDir).exists()){ + QDir().mkdir(GlobalVars::VagoTemporaryDir); + } + // Get data page 2 if(field("rbOther").toBool()){ outputFolder=field("leOtherLocation").toString(); @@ -76,14 +90,15 @@ void SoundPageFinal::startProcessing(){ outputFolder=this->soundsLocation; } - outputFolder = Util::insertQuotes(outputFolder); // for onisplit work correctly - // Get data page 3 priorityLow=field("rbPriorityLow").toBool(); priorityNormal=field("rbPriorityNormal").toBool(); priorityHigh=field("rbPriorityHigh").toBool(); priorityHighest=field("rbPriorityHighest").toBool(); + interruptOnStop=field("cbInterruptOnStop").toBool(); + playOnce=field("cbPlayOnce").toBool(); + canPan=field("cbCanPan").toBool(); if(priorityNormal){ priority="Normal"; @@ -110,10 +125,6 @@ void SoundPageFinal::startProcessing(){ flags << "CanPan"; } - interruptOnStop=field("cbInterruptOnStop").toBool(); - playOnce=field("cbPlayOnce").toBool(); - canPan=field("cbCanPan").toBool(); - sphereRadious=Util::normalizeDecimalSeparator(field("leSphereRadious").toString()); minElapsedTime=Util::normalizeDecimalSeparator(field("leMinElapsedTime").toString()); maxElapsedTime=Util::normalizeDecimalSeparator(field("leMaxElapsedTime").toString()); @@ -144,6 +155,34 @@ void SoundPageFinal::startProcessing(){ else if(mono22){ numberChannels="1"; } + + // Get data page 5 + priorityLowImp=field("rbPriorityLowImp").toBool(); + priorityNormalImp=field("rbPriorityNormalImp").toBool(); + priorityHighImp=field("rbPriorityHighImp").toBool(); + priorityHighestImp=field("rbPriorityHighestImp").toBool(); + + if(priorityNormalImp){ + priorityImp="Normal"; + } + else if(priorityLowImp){ + priorityImp="Low"; + } + else if(priorityHighImp){ + priorityImp="High"; + } + else if(priorityHighestImp){ + priorityImp="Highest"; + } + + minVolumeDistanceImp=Util::normalizeDecimalSeparator(field("leMinVolumeDistanceImp").toString()); + maxVolumeDistanceImp=Util::normalizeDecimalSeparator(field("leMaxVolumeDistanceImp").toString()); + minAngleImp=Util::normalizeDecimalSeparator(field("leMinAngleImp").toString()); + maxAngleImp=Util::normalizeDecimalSeparator(field("leMaxAngleImp").toString()); + minAttenuationImp=Util::normalizeDecimalSeparator(field("leMinAttenuationImp").toString()); + impactVelocityImp=Util::normalizeDecimalSeparator(field("leImpactVelocityImp").toString()); + minOcclusionImp=Util::normalizeDecimalSeparator(field("leMinOcclusionImp").toString()); + //######################################################### Starting xml processing // Clean tmp dir @@ -159,15 +198,18 @@ void SoundPageFinal::startProcessing(){ // Copy sample xml files to tmp dir QFile::copy(":/new/sampleFiles/"+ambFile , ambFileLocation); QFile::copy(":/new/sampleFiles/"+grpFile , grpFileLocation); + QFile::copy(":/new/sampleFiles/"+impFile , impFileLocation); QFile::setPermissions(ambFileLocation, QFile::ReadOwner | QFile::WriteOwner); //remove read only attribute that come from resources QFile::setPermissions(grpFileLocation, QFile::ReadOwner | QFile::WriteOwner); + QFile::setPermissions(impFileLocation, QFile::ReadOwner | QFile::WriteOwner); (*this->xmlCommands) << "--replace-all-values -e Priority -n "+Util::insertQuotes(priority)+" -f "+Util::insertQuotes(ambFileLocation)+" --no-backups --no-verbose" - << "--replace-all-values -e Flags -n "+(flags.join(" ").isEmpty() ? "\" \"" : Util::insertQuotes(flags.join(" ")))+" -f "+Util::insertQuotes(ambFileLocation)+" --no-backups --no-verbose" + << "--replace-all-values -e Flags -n "+(flags.join(" ").isEmpty() ? Util::insertQuotes("") : Util::insertQuotes(flags.join(" ")))+" -f "+Util::insertQuotes(ambFileLocation)+" --no-backups --no-verbose" << "--replace-all-values -e SphereRadius -n "+Util::insertQuotes(sphereRadious)+" -f "+Util::insertQuotes(ambFileLocation)+" --no-backups --no-verbose" << "--replace-all-values -e Treshold -n "+Util::insertQuotes(treshold)+" -f "+Util::insertQuotes(ambFileLocation)+" --no-backups --no-verbose" << "--replace-all-values -e MinOcclusion -n "+Util::insertQuotes(minOcclusion)+" -f "+Util::insertQuotes(ambFileLocation)+" --no-backups --no-verbose" + << "--replace-all-values --parent-element-name ElapsedTime -e Max -n "+Util::insertQuotes(maxElapsedTime)+" -f "+Util::insertQuotes(ambFileLocation)+" --no-backups --no-verbose" << "--replace-all-values --parent-element-name ElapsedTime -e Min -n "+Util::insertQuotes(minElapsedTime)+" -f "+Util::insertQuotes(ambFileLocation)+" --no-backups --no-verbose" << "--replace-all-values --parent-element-name Distance -e Max -n "+Util::insertQuotes(maxVolumeDistance)+" -f "+Util::insertQuotes(ambFileLocation)+" --no-backups --no-verbose" << "--replace-all-values --parent-element-name Distance -e Min -n "+Util::insertQuotes(minVolumeDistance)+" -f "+Util::insertQuotes(ambFileLocation)+" --no-backups --no-verbose" @@ -178,7 +220,15 @@ void SoundPageFinal::startProcessing(){ << "--replace-all-values --parent-element-name Volume -e Max -n "+Util::insertQuotes(maxVolume)+" -f "+Util::insertQuotes(grpFileLocation)+" --no-backups --no-verbose" << "--replace-all-values --parent-element-name Pitch -e Min -n "+Util::insertQuotes(minPitch)+" -f "+Util::insertQuotes(grpFileLocation)+" --no-backups --no-verbose" << "--replace-all-values --parent-element-name Pitch -e Max -n "+Util::insertQuotes(maxPitch)+" -f "+Util::insertQuotes(grpFileLocation)+" --no-backups --no-verbose" - << "--replace-all-values -e Weight -n "+Util::insertQuotes(weight)+" -f "+Util::insertQuotes(grpFileLocation)+" --no-backups --no-verbose"; + << "--replace-all-values -e Weight -n "+Util::insertQuotes(weight)+" -f "+Util::insertQuotes(grpFileLocation)+" --no-backups --no-verbose" + << "--replace-all-values -e Priority -n "+Util::insertQuotes(priorityImp)+" -f "+Util::insertQuotes(impFileLocation)+" --no-backups --no-verbose" + << "--replace-all-values --parent-element-name Distance -e Min -n "+Util::insertQuotes(minVolumeDistanceImp)+" -f "+Util::insertQuotes(impFileLocation)+" --no-backups --no-verbose" + << "--replace-all-values --parent-element-name Distance -e Max -n "+Util::insertQuotes(maxVolumeDistanceImp)+" -f "+Util::insertQuotes(impFileLocation)+" --no-backups --no-verbose" + << "--replace-all-values --parent-element-name Angle -e Min -n "+Util::insertQuotes(minAngleImp)+" -f "+Util::insertQuotes(impFileLocation)+" --no-backups --no-verbose" + << "--replace-all-values --parent-element-name Angle -e Max -n "+Util::insertQuotes(maxAngleImp)+" -f "+Util::insertQuotes(impFileLocation)+" --no-backups --no-verbose" + << "--replace-all-values -e MinAttenuation -n "+Util::insertQuotes(minAttenuationImp)+" -f "+Util::insertQuotes(impFileLocation)+" --no-backups --no-verbose" + << "--replace-all-values -e ImpactVelocity -n "+Util::insertQuotes(impactVelocityImp)+" -f "+Util::insertQuotes(impFileLocation)+" --no-backups --no-verbose" + << "--replace-all-values -e MinOcclusion -n "+Util::insertQuotes(minOcclusionImp)+" -f "+Util::insertQuotes(impFileLocation)+" --no-backups --no-verbose"; if(preventRepeat){ (*this->xmlCommands) << "--replace-all-values --parent-element-name SoundGroup -e Flags -n PreventRepeat -f "+Util::insertQuotes(grpFileLocation)+" --no-backups --no-verbose"; @@ -190,33 +240,35 @@ void SoundPageFinal::startProcessing(){ QString currFileName; QString currGrpFileLocation; QString currAmbFileLocation; + QString currImpFileLocation; for(int i=0; ipage2Table->rowCount(); i++){ - (*this->oniSplitCommands) << this->commandMap->value("xml->XML->ONI")+" "+outputFolder+" "+Util::insertQuotes(this->page2Table->item(i,1)->text()); // add location of sound file to convert + (*this->oniSplitCommands) << this->commandMap->value("xml->XML->ONI")+" "+Util::insertQuotes(outputFolder)+" "+Util::insertQuotes(this->page2Table->item(i,1)->text()); // add location of sound file to convert currFileName=this->page2Table->item(i,0)->text(); // get current file name - currAmbFileLocation = QString(ambFileLocation).replace("sample_file",currFileName); // get the new files, filenames - currGrpFileLocation = QString(grpFileLocation).replace("sample_file",currFileName); + currAmbFileLocation = outputFolder + "/" + QString(ambFile).replace("sample_file",currFileName); // get the new files, filenames + currGrpFileLocation = outputFolder + "/" + QString(grpFile).replace("sample_file",currFileName); + currImpFileLocation = outputFolder + "/" + QString(impFile).replace("sample_file",currFileName); QFile::copy(ambFileLocation, currAmbFileLocation); // make a copy of the sample files that will be the real files QFile::copy(grpFileLocation, currGrpFileLocation); + QFile::copy(impFileLocation, currImpFileLocation); (*this->xmlCommands) << "--replace-all-values -e BaseTrack1 -n "+Util::insertQuotes(currFileName)+" -f "+Util::insertQuotes(currAmbFileLocation)+" --no-backups --no-verbose" // process the xml - << "--replace-all-values -e Sound -n "+Util::insertQuotes(currFileName)+" -f "+Util::insertQuotes(currGrpFileLocation)+" --no-backups --no-verbose"; + << "--replace-all-values -e Sound -n "+Util::insertQuotes(currFileName)+" -f "+Util::insertQuotes(currGrpFileLocation)+" --no-backups --no-verbose" + << "--replace-all-values -e Group -n "+Util::insertQuotes(currFileName)+" -f "+Util::insertQuotes(currImpFileLocation)+" --no-backups --no-verbose"; myXmlProcessor->start(); myXmlProcessor->wait(); // Wait until all xml is edited - } - (*this->oniSplitCommands) << this->commandMap->value("xml->XML->ONI")+" "+outputFolder+" "+Util::insertQuotes(GlobalVars::VagoTemporaryDir+"/*.xml"); + (*this->oniSplitCommands) << this->commandMap->value("xml->XML->ONI")+" "+Util::insertQuotes(outputFolder)+" "+Util::insertQuotes(currAmbFileLocation); + (*this->oniSplitCommands) << this->commandMap->value("xml->XML->ONI")+" "+Util::insertQuotes(outputFolder)+" "+Util::insertQuotes(currGrpFileLocation); + (*this->oniSplitCommands) << this->commandMap->value("xml->XML->ONI")+" "+Util::insertQuotes(outputFolder)+" "+Util::insertQuotes(currImpFileLocation); + } this->myConverter->start(); // finally process the onisplit commands this->myConverter->wait(); // wait for it to complete - - // Finally remove the sample files, since not needed anymore - QFile(ambFileLocation).remove(); - QFile(grpFileLocation).remove(); } void SoundPageFinal::catchXmlAndOSplitProcessingError(QString result, int numErrors){ @@ -224,7 +276,7 @@ void SoundPageFinal::catchXmlAndOSplitPr if(numErrors!=0){ QString sNumErrors=QString::number(numErrors); if(numErrors>1){ - UtilVago::showErrorPopUpLogButton(result+"\n This is the last of " + sNumErrors + " Errors."); + UtilVago::showErrorPopUpLogButton(result+"\n This is the last of " + sNumErrors + " errors."); } else{ UtilVago::showErrorPopUpLogButton(result);