本文整理汇总了C++中AudioPluginInstance类的典型用法代码示例。如果您正苦于以下问题:C++ AudioPluginInstance类的具体用法?C++ AudioPluginInstance怎么用?C++ AudioPluginInstance使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了AudioPluginInstance类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: strtoqstr
void
AudioPluginOSCGUIManager::updateProgram(InstrumentId instrument, int position)
{
RG_DEBUG << "AudioPluginOSCGUIManager::updateProgram(" << instrument << ","
<< position << ")" << endl;
if (m_guis.find(instrument) == m_guis.end() ||
m_guis[instrument].find(position) == m_guis[instrument].end())
return ;
PluginContainer *container = 0;
container = m_studio->getContainerById(instrument);
if (!container) return;
AudioPluginInstance *pluginInstance = container->getPlugin(position);
if (!pluginInstance) return;
unsigned long rv = StudioControl::getPluginProgram
(pluginInstance->getMappedId(),
strtoqstr(pluginInstance->getProgram()));
int bank = rv >> 16;
int program = rv - (bank << 16);
RG_DEBUG << "AudioPluginOSCGUIManager::updateProgram(" << instrument << ","
<< position << "): rv " << rv << ", bank " << bank << ", program " << program << endl;
m_guis[instrument][position]->sendProgram(bank, program);
}
示例2:
void
AudioPluginOSCGUIManager::updatePort(InstrumentId instrument, int position,
int port)
{
RG_DEBUG << "AudioPluginOSCGUIManager::updatePort(" << instrument << ","
<< position << "," << port << ")" << endl;
if (m_guis.find(instrument) == m_guis.end() ||
m_guis[instrument].find(position) == m_guis[instrument].end())
return ;
PluginContainer *container = 0;
container = m_studio->getContainerById(instrument);
if (!container) return;
AudioPluginInstance *pluginInstance = container->getPlugin(position);
if (!pluginInstance)
return ;
PluginPortInstance *porti = pluginInstance->getPort(port);
if (!porti)
return ;
RG_DEBUG << "AudioPluginOSCGUIManager::updatePort(" << instrument << ","
<< position << "," << port << "): value " << porti->value << endl;
m_guis[instrument][position]->sendPortValue(port, porti->value);
}
示例3: RT_process
static void RT_process(SoundPlugin *plugin, int64_t time, int num_frames, float **inputs, float **outputs){
Data *data = (Data*)plugin->data;
#if 0
for(int ch=0; ch<data->num_output_channels ; ch++)
memset(outputs[ch], 0, sizeof(float)*num_frames);
return;
#endif
// 1. Process audio
AudioPluginInstance *instance = data->audio_instance;
AudioSampleBuffer &buffer = data->buffer;
for(int ch=0; ch<data->num_input_channels ; ch++)
memcpy(buffer.getWritePointer(ch), inputs[ch], sizeof(float)*num_frames);
int pos = CRASHREPORTER_set_plugin_name(plugin->type->name);{
instance->processBlock(buffer, data->midi_buffer);
}CRASHREPORTER_unset_plugin_name(pos);
for(int ch=0; ch<data->num_output_channels ; ch++)
memcpy(outputs[ch], buffer.getReadPointer(ch), sizeof(float)*num_frames);
// 2. Send out midi (untested, need plugin to test with)
volatile struct Patch *patch = plugin->patch;
if (patch!=NULL) {
MidiBuffer::Iterator iterator(data->midi_buffer);
MidiMessage message;
int samplePosition;
while(iterator.getNextEvent(message, samplePosition)){
#ifndef RELEASE
if (samplePosition >= num_frames || samplePosition < 0)
RT_message("The instrument named \"%s\" of type %s/%s\n"
"returned illegal sample position: %d",
patch==NULL?"<no name>":patch->name,
plugin->type->type_name, plugin->type->name,
samplePosition
);
#endif
// Make sure samplePosition has a legal value
if (samplePosition >= num_frames)
samplePosition = num_frames-1;
if (samplePosition < 0)
samplePosition = 0;
int64_t delta_time = PLAYER_get_block_delta_time(pc->start_time+samplePosition);
int64_t radium_time = pc->start_time + delta_time;
RT_MIDI_send_msg_to_patch_receivers((struct Patch*)patch, message, radium_time);
}
}
}
示例4: get_current_preset
static int get_current_preset(struct SoundPlugin *plugin){
#if JUCE_LINUX
const MessageManagerLock mmLock;
#endif
Data *data = (Data*)plugin->data;
AudioPluginInstance *instance = data->audio_instance;
return instance->getCurrentProgram();
}
示例5: set_current_preset
static void set_current_preset(struct SoundPlugin *plugin, int num){
#if JUCE_LINUX
const MessageManagerLock mmLock;
#endif
Data *data = (Data*)plugin->data;
AudioPluginInstance *instance = data->audio_instance;
instance->setCurrentProgram(num);
}
示例6: talloc_strdup
static const char *get_preset_name(struct SoundPlugin *plugin, int num){
#if JUCE_LINUX
const MessageManagerLock mmLock;
#endif
Data *data = (Data*)plugin->data;
AudioPluginInstance *instance = data->audio_instance;
return talloc_strdup(instance->getProgramName(num).toRawUTF8());
}
示例7: set_preset_name
static void set_preset_name(struct SoundPlugin *plugin, int num, const char* new_name){
#if JUCE_LINUX
const MessageManagerLock mmLock;
#endif
Data *data = (Data*)plugin->data;
AudioPluginInstance *instance = data->audio_instance;
instance->changeProgramName(num, new_name);
}
示例8: checkOSCThread
void
AudioPluginOSCGUIManager::startGUI(InstrumentId instrument, int position)
{
RG_DEBUG << "AudioPluginOSCGUIManager::startGUI: " << instrument << "," << position
<< endl;
checkOSCThread();
if (m_guis.find(instrument) != m_guis.end() &&
m_guis[instrument].find(position) != m_guis[instrument].end()) {
RG_DEBUG << "stopping GUI first";
stopGUI(instrument, position);
}
// check the label
PluginContainer *container = 0;
container = m_studio->getContainerById(instrument);
if (!container) {
RG_DEBUG << "AudioPluginOSCGUIManager::startGUI: no such instrument or buss as "
<< instrument << endl;
return;
}
AudioPluginInstance *pluginInstance = container->getPlugin(position);
if (!pluginInstance) {
RG_DEBUG << "AudioPluginOSCGUIManager::startGUI: no plugin at position "
<< position << " for instrument " << instrument << endl;
return ;
}
try {
AudioPluginOSCGUI *gui =
new AudioPluginOSCGUI(pluginInstance,
getOSCUrl(instrument,
position,
strtoqstr(pluginInstance->getIdentifier())),
getFriendlyName(instrument,
position,
strtoqstr(pluginInstance->getIdentifier())));
m_guis[instrument][position] = gui;
} catch (Exception e) {
RG_DEBUG << "AudioPluginOSCGUIManager::startGUI: failed to start GUI: "
<< e.getMessage() << endl;
}
}
示例9: formatFilterModel
FilterModel FilterGraph::formatFilterModel (AudioProcessorGraph::Node* const node)
{
//FOR SAVING AND UPDATING
FilterModel filter;
AudioPluginInstance* plugin = dynamic_cast<AudioPluginInstance*>(node->getProcessor());
if (plugin == nullptr) {
jassertfalse;
return filter;
}
PluginDescription pd;
plugin->fillInPluginDescription(pd);
fill_in_filter_pd_info(node, filter, pd);
return filter;
}
示例10: return
bool
AudioPluginOSCGUIManager::hasGUI(InstrumentId instrument, int position)
{
PluginContainer *container = 0;
container = m_studio->getContainerById(instrument);
if (!container) return false;
AudioPluginInstance *pluginInstance = container->getPlugin(position);
if (!pluginInstance) return false;
try {
QString filePath = AudioPluginOSCGUI::getGUIFilePath
(strtoqstr(pluginInstance->getIdentifier()));
return ( !filePath.isEmpty() );
} catch (Exception e) { // that's OK
return false;
}
}
示例11: resolveRelativePath
// The caller is responsible for deleting the object that is returned
AudioPluginInstance *createSynthInstance() {
AudioPluginFormatManager pluginManager;
pluginManager.addDefaultFormats();
PluginDescription desc;
desc.fileOrIdentifier = resolveRelativePath(PLUGIN_REL_PATH);
// DBG << desc.fileOrIdentifier << endl;
desc.uid = 0;
String errorMessage;
AudioPluginInstance *instance = pluginManager.createPluginInstance(desc, errorMessage);
if (!instance) {
DBG << "Error creating plugin instance: " << errorMessage << endl;
exit(1);
}
// Force initialization on the main thread. This preparation will redone with proper values later.
instance->prepareToPlay(44100, 512);
return instance;
}
示例12: String
static AudioPluginInstance *get_audio_instance(const TypeData *type_data, float sample_rate, int block_size){
static bool inited=false;
static AudioPluginFormatManager formatManager;
if (inited==false){
formatManager.addDefaultFormats();
inited=true;
}
//int uid = VST_get_uid(type_data->library_file_full_path);
//printf("uid: %d\n",uid);
//getchar();
//((PluginDescription*)description)->uid = uid;
//if (uid==-1)
// return NULL;
String errorMessage;
PluginDescription description;
description.fileOrIdentifier = String(type_data->file_or_identifier);
description.uid = type_data->uid;
AudioPluginInstance *instance = formatManager.createPluginInstance(description,sample_rate,block_size,errorMessage);
if (instance==NULL){
GFX_Message(NULL, "Unable to open VST plugin %s: %s\n",description.fileOrIdentifier.toRawUTF8(), errorMessage.toRawUTF8());
return NULL;
}
instance->setPlayHead(&myAudioPlayHead);
instance->prepareToPlay(sample_rate, block_size);
return instance;
}
示例13: pluginStr
bool
AudioPluginOSCGUIManager::parseOSCPath(QString path, InstrumentId &instrument,
int &position, QString &method)
{
RG_DEBUG << "AudioPluginOSCGUIManager::parseOSCPath(" << path << ")";
if (!m_studio)
return false;
QString pluginStr("/plugin/");
if (path.startsWith("//")) {
path = path.right(path.length() - 1);
}
if (!path.startsWith(pluginStr)) {
RG_DEBUG << "AudioPluginOSCGUIManager::parseOSCPath: malformed path "
<< path << endl;
return false;
}
path = path.right(path.length() - pluginStr.length());
QString type = path.section('/', 0, 0);
QString instrumentStr = path.section('/', 1, 1);
QString positionStr = path.section('/', 2, 2);
QString label = path.section('/', 3, -2);
method = path.section('/', -1, -1);
if (instrumentStr.isEmpty() || positionStr.isEmpty() ) {
RG_DEBUG << "AudioPluginOSCGUIManager::parseOSCPath: no instrument or position in " << path;
return false;
}
instrument = instrumentStr.toUInt();
if (positionStr == "synth") {
position = Instrument::SYNTH_PLUGIN_POSITION;
} else {
position = positionStr.toInt();
}
// check the label
PluginContainer *container = m_studio->getContainerById(instrument);
if (!container) {
RG_DEBUG << "AudioPluginOSCGUIManager::parseOSCPath: no such instrument or buss as "
<< instrument << " in path " << path << endl;
return false;
}
AudioPluginInstance *pluginInstance = container->getPlugin(position);
if (!pluginInstance) {
RG_DEBUG << "AudioPluginOSCGUIManager::parseOSCPath: no plugin at position "
<< position << " for instrument " << instrument << " in path "
<< path << endl;
return false;
}
QString identifier = strtoqstr(pluginInstance->getIdentifier());
QString iType, iSoName, iLabel;
PluginIdentifier::parseIdentifier(identifier, iType, iSoName, iLabel);
if (iLabel != label) {
RG_DEBUG << "AudioPluginOSCGUIManager::parseOSCPath: wrong label for plugin"
<< " at position " << position << " for instrument " << instrument
<< " in path " << path << " (actual label is " << iLabel
<< ")" << endl;
return false;
}
RG_DEBUG << "AudioPluginOSCGUIManager::parseOSCPath: good path " << path
<< ", got mapped id " << pluginInstance->getMappedId() << endl;
return true;
}
示例14: createNodeXml
XmlElement* PMixDocument::createNodeXml (AudioProcessorGraph::Node* const node) noexcept
{
AudioPluginInstance* plugin = dynamic_cast <AudioPluginInstance*> (node->getProcessor());
if (plugin == nullptr)
{
jassertfalse;
return nullptr;
}
XmlElement* e = new XmlElement ("NODE");
e->setAttribute ("uid", (int) node->nodeID);
e->setAttribute ("x", node->properties ["x"].toString());
e->setAttribute ("y", node->properties ["y"].toString());
e->setAttribute ("uiLastX", node->properties ["uiLastX"].toString());
e->setAttribute ("uiLastY", node->properties ["uiLastY"].toString());
e->setAttribute ("uiStatus", node->properties ["uiStatus"].toString());
PluginDescription pd;
plugin->fillInPluginDescription (pd);
if(!InternalPluginFormat::isInternalFormat(pd.name))
{
e->setAttribute("colour", node->properties ["colour"].toString());
e->setAttribute ("iposx", node->properties ["iposx"].toString());
e->setAttribute ("iposy", node->properties ["iposy"].toString());
}
e->addChildElement (pd.createXml());
XmlElement* state = new XmlElement ("STATE");
MemoryBlock m;
node->getProcessor()->getStateInformation (m);
state->addTextElement (m.toBase64Encoding());
e->addChildElement (state);
if(!InternalPluginFormat::isInternalFormat(pd.name))
{
XmlElement* params = new XmlElement ("PARAMS");
Array<var>* paramsArray = node->properties.getVarPointer("params")->getArray();
params->addTextElement("[");
for(int i=0;i<paramsArray->size();i++)
{
var parameterIdx = paramsArray->getReference(i);
params->addTextElement(parameterIdx.toString());
if(i != paramsArray->size()-1)
params->addTextElement(", ");
}
params->addTextElement("]");
e->addChildElement(params);
Array<var>* presetsArr = node->properties.getVarPointer("presets")->getArray();
for(int i=0;i<presetsArr->size();i++)
{
XmlElement* presetXML = new XmlElement ("PRESET");
DynamicObject* thePreset = presetsArr->getReference(i).getDynamicObject();
presetXML->setAttribute("name", thePreset->getProperty("name").toString());
presetXML->setAttribute("x", thePreset->getProperty("x").toString());
presetXML->setAttribute("y", thePreset->getProperty("y").toString());
presetXML->setAttribute("radius", thePreset->getProperty("radius").toString());
presetXML->setAttribute("hidden", thePreset->getProperty("hidden").toString());
//presetXML->setAttribute("distance", thePreset->getProperty("distance").toString());
presetXML->setAttribute("coeff", thePreset->getProperty("coeff").toString());
presetXML->setAttribute("uid", thePreset->getProperty("uid").toString());
Array<var>* paramsArray = thePreset->getProperty("state").getArray();
presetXML->addTextElement("[");
for(int i=0;i<paramsArray->size();i++)
{
var parameterIdx = paramsArray->getReference(i);
presetXML->addTextElement(parameterIdx.toString());
if(i != paramsArray->size()-1)
presetXML->addTextElement(", ");
}
presetXML->addTextElement("]");
e->addChildElement(presetXML);
}
}
return e;
}
示例15: handlePluginRequest
bool handlePluginRequest(const PluginRequestParameters ¶ms, OutputStream &ostream,
ThreadSafePlugin *plugin = nullptr) {
if (!plugin) {
// It's very possible that all of this was a premature optimization.
// For VSTs at least, code loading and caching is handled by ModuleHandle::findOrCreateModule,
// and each instantiation only requires a couple of disc hits for working directory setting.
// On the other hand, we want to make sure that each audio request has a "fresh" instance.
// The easiest way to do this is by bypassing the instance pool and instantiating on demand.
#if PLUGIN_POOL_SIZE
// Recurse with a plugin from the pool, locking on it.
// Keep trying with a delay until a timeout occurs.
const int TIMEOUT = 5000, WAIT = 200;
int64 startTime = Time::currentTimeMillis();
while (Time::currentTimeMillis() < startTime + TIMEOUT) {
int i = 0;
while ((plugin = pluginPool[i++])) {
const ScopedTryLock pluginTryLock(plugin->crit);
if (pluginTryLock.isLocked()) {
DBG << "Handling with plugin " << i << endl;
return handlePluginRequest(params, ostream, plugin);
}
}
DBG << "Trying again in " << WAIT << endl;
Thread::sleep(WAIT);
}
// If we were unable to obtain a lock, return failure.
DBG << "Timeout" << endl;
return false;
#else
ThreadSafePlugin temporaryPlugin(createSynthInstance());
return handlePluginRequest(params, ostream, &temporaryPlugin);
#endif
}
else {
// Re-acquire or acquire the lock.
const ScopedLock pluginLock(plugin->crit);
AudioPluginInstance *instance = plugin->instance; // unmanaged, for simplicity
// Attempt to reset the plugin in all ways possible.
instance->reset();
// Setting default parameters here causes miniTERA to become unresponsive to parameter settings.
// It's possible that it's effectively pressing some interface buttons that change the editor mode entirely.
// It's not necessary anyways if the plugin instance has been freshly created (see above).
// pluginParametersOldNewFallback(instance, nullptr, &pluginDefaults); // note that the defaults may be empty
instance->setCurrentProgram(0);
// Load preset if specified, before listing or modifying parameters!
if (params.presetNumber >= 0 && params.presetNumber < instance->getNumPrograms()) {
DBG << "Setting program/preset: " << params.presetNumber << endl;
instance->setCurrentProgram(params.presetNumber);
}
int currentProgram = instance->getCurrentProgram();
DBG << "Current program/preset: " << currentProgram << " - " << instance->getProgramName(currentProgram) << endl;
// Set parameters, starting with named, then indexed
pluginParametersSet(instance, params.parameters);
pluginParametersSetIndexed(instance, params.indexedParameters);
// If parameters requested, output them and return
if (params.listParameters) {
DBG << "Rendering parameter list: # parameters " << instance->getNumPrograms() << endl;
// Output each parameter setting in two places:
// an indexed array and a dictionary by name
// All DynamicObjects created will be freed when their var's leave scope.
DynamicObject *outer = new DynamicObject();
DynamicObject *innerParams = new DynamicObject();
var indexedParamVar;
{
for (int i = 0, n = instance->getNumParameters(); i < n; ++i) {
String name = instance->getParameterName(i);
float val = instance->getParameter(i);
innerParams->setProperty(name, val);
DynamicObject *indexedInnerObj = new DynamicObject();
indexedInnerObj->setProperty("index", i);
indexedInnerObj->setProperty("name", name);
indexedInnerObj->setProperty("value", val);
indexedParamVar.append(var(indexedInnerObj)); // frees indexedInnerObj when this scope ends
}
}
outer->setProperty(Identifier("parameters"), var(innerParams));
outer->setProperty(Identifier("indexedParameters"), indexedParamVar);
// List presets/programs.
var progVar;
{
for (int i = 0, n = instance->getNumPrograms(); i < n; ++i) {
progVar.append(var(instance->getProgramName(i)));
}
}
outer->setProperty(Identifier("presets"), progVar);
//.........这里部分代码省略.........