void patmanInstrument::setFile( const QString & _patch_file, bool _rename ) { if( _patch_file.size() <= 0 ) { m_patchFile = QString::null; return; } // is current instrument-track-name equal to previous-filename?? if( _rename && ( instrumentTrack()->name() == QFileInfo( m_patchFile ).fileName() || m_patchFile == "" ) ) { // then set it to new one instrumentTrack()->setName( QFileInfo( _patch_file ).fileName() ); } // else we don't touch the instrument-track-name, because the user // named it self m_patchFile = sampleBuffer::tryToMakeRelative( _patch_file ); LoadErrors error = loadPatch( sampleBuffer::tryToMakeAbsolute( _patch_file ) ); if( error ) { printf("Load error\n"); } emit fileChanged(); }
bool Resource::loadFromAudioVolumeSCI11(Common::SeekableReadStream *file) { // Check for WAVE files here uint32 riffTag = file->readUint32BE(); if (riffTag == MKTAG('R','I','F','F')) { _size = file->readUint32LE() + 8; file->seek(-8, SEEK_CUR); return loadFromWaveFile(file); } file->seek(-4, SEEK_CUR); // Rave-resources (King's Quest 6) don't have any header at all if (getType() != kResourceTypeRave) { ResourceType type = _resMan->convertResType(file->readByte()); if (((getType() == kResourceTypeAudio || getType() == kResourceTypeAudio36) && (type != kResourceTypeAudio)) || ((getType() == kResourceTypeSync || getType() == kResourceTypeSync36) && (type != kResourceTypeSync))) { warning("Resource type mismatch loading %s", _id.toString().c_str()); unalloc(); return false; } const uint8 headerSize = file->readByte(); if (type == kResourceTypeAudio) { if (headerSize != 7 && headerSize != 11 && headerSize != 12) { warning("Unsupported audio header size %d in %s", headerSize, _id.toString().c_str()); unalloc(); return false; } if (headerSize != 7) { // Size is defined already from the map // Load sample size file->seek(7, SEEK_CUR); _size = file->readUint32LE() + headerSize + kResourceHeaderSize; if (file->err() || file->eos()) { warning("Error while reading size of %s", _id.toString().c_str()); unalloc(); return false; } // Adjust offset to point at the beginning of the audio file // again file->seek(-11, SEEK_CUR); } // SOL audio files are designed to require the resource header file->seek(-2, SEEK_CUR); } } return loadPatch(file); }
void InstanceProcessor::setStateInformation (const void* data, int sizeInBytes) { ScopedPointer<XmlElement> xml(getXmlFromBinary(data, sizeInBytes)); if(xml != nullptr) { if(xml->hasTagName("CamomileSettings")) { String name = xml->getStringAttribute("name"); String path = xml->getStringAttribute("path"); if(File::isAbsolutePath(path)) { File file(path + File::separatorString + name); if(!file.exists()) { file = File(m_path + File::separatorString + name); if(!file.exists()) { file = File(File::getCurrentWorkingDirectory().getFullPathName() + File::separatorString + name); if(!file.exists()) { file = File(File::getSpecialLocation(juce::File::SpecialLocationType::userDocumentsDirectory).getFullPathName() + File::separatorString + name); if(!file.exists()) { file = File(path + File::separatorString + name); } } } } loadPatch(name.toStdString(), path.toStdString()); } XmlElement* params = xml->getChildByName(juce::StringRef("params")); if(params) { for(int i = 0; i < params->getNumAttributes(); i++) { int index = getParameterIndex(params->getAttributeName(i)); if(index >= 0) { setParameterNotifyingHost(index, params->getAttributeValue(i).getDoubleValue()); } } } } } }
bool Resource::loadFromAudioVolumeSCI11(Common::SeekableReadStream *file) { // Check for WAVE files here uint32 riffTag = file->readUint32BE(); if (riffTag == MKTAG('R','I','F','F')) { _headerSize = 0; size = file->readUint32LE() + 8; file->seek(-8, SEEK_CUR); return loadFromWaveFile(file); } file->seek(-4, SEEK_CUR); // Rave-resources (King's Quest 6) don't have any header at all if (getType() != kResourceTypeRave) { ResourceType type = _resMan->convertResType(file->readByte()); if (((getType() == kResourceTypeAudio || getType() == kResourceTypeAudio36) && (type != kResourceTypeAudio)) || ((getType() == kResourceTypeSync || getType() == kResourceTypeSync36) && (type != kResourceTypeSync))) { warning("Resource type mismatch loading %s", _id.toString().c_str()); unalloc(); return false; } _headerSize = file->readByte(); if (type == kResourceTypeAudio) { if (_headerSize != 7 && _headerSize != 11 && _headerSize != 12) { warning("Unsupported audio header"); unalloc(); return false; } if (_headerSize != 7) { // Size is defined already from the map // Load sample size file->seek(7, SEEK_CUR); size = file->readUint32LE(); // Adjust offset to point at the header data again file->seek(-11, SEEK_CUR); } } } return loadPatch(file); }
void loadCurrentPatch() { loadPatch( &patches[ patchSection.bankLed->getValue() * 10 + patchSection.patchLed->getValue() ] ); }