Browse Source

Update Info example

pull/2/head
falkTX 7 years ago
parent
commit
fb3040ba95
6 changed files with 88 additions and 38 deletions
  1. +6
    -0
      Makefile
  2. +1
    -1
      dpf
  3. +1
    -1
      plugins/Info/DistrhoPluginInfo.h
  4. +59
    -20
      plugins/Info/ExamplePluginInfo.cpp
  5. +15
    -12
      plugins/Info/ExampleUIInfo.cpp
  6. +6
    -4
      plugins/Info/README.md

+ 6
- 0
Makefile View File

@@ -4,12 +4,16 @@
# Created by falkTX
#

include Makefile.mk

all: libs plugins gen

# --------------------------------------------------------------

libs:
ifeq ($(HAVE_DGL),true)
$(MAKE) -C dpf/dgl
endif

plugins: libs
$(MAKE) all -C plugins/Info
@@ -29,7 +33,9 @@ dpf/utils/lv2_ttl_generator:
# --------------------------------------------------------------

clean:
ifeq ($(HAVE_DGL),true)
$(MAKE) clean -C dpf/dgl
endif
$(MAKE) clean -C dpf/utils/lv2-ttl-generator
$(MAKE) clean -C plugins/Info
$(MAKE) clean -C plugins/Meters


+ 1
- 1
dpf

@@ -1 +1 @@
Subproject commit e14e5a64ee0e79f6942713cb2282f4983e6dc166
Subproject commit 0d5de799d92ba839f5b097f6c1ae40dd350a1feb

+ 1
- 1
plugins/Info/DistrhoPluginInfo.h View File

@@ -1,6 +1,6 @@
/*
* DISTRHO Plugin Framework (DPF)
* Copyright (C) 2012-2014 Filipe Coelho <falktx@falktx.com>
* Copyright (C) 2012-2015 Filipe Coelho <falktx@falktx.com>
*
* Permission to use, copy, modify, and/or distribute this software for any purpose with
* or without fee is hereby granted, provided that the above copyright notice and this


+ 59
- 20
plugins/Info/ExamplePluginInfo.cpp View File

@@ -1,6 +1,6 @@
/*
* DISTRHO Plugin Framework (DPF)
* Copyright (C) 2012-2014 Filipe Coelho <falktx@falktx.com>
* Copyright (C) 2012-2015 Filipe Coelho <falktx@falktx.com>
*
* Permission to use, copy, modify, and/or distribute this software for any purpose with
* or without fee is hereby granted, provided that the above copyright notice and this
@@ -21,15 +21,19 @@ START_NAMESPACE_DISTRHO
// -----------------------------------------------------------------------------------------------------------
/**
Plugin to demonstrate parameter outputs using meters.
Plugin to show how to get some basic information sent to the UI.
*/
class ExamplePluginInfo : public Plugin
class InfoExamplePlugin : public Plugin
{
public:
ExamplePluginInfo()
InfoExamplePlugin()
: Plugin(kParameterCount, 0, 0)
{
// clear all parameters
std::memset(fParameters, 0, sizeof(float)*kParameterCount);
// we can know buffer-size right at the start
fParameters[kParameterBufferSize] = getBufferSize();
}
protected:
@@ -38,11 +42,11 @@ protected:
/**
Get the plugin label.
A plugin label follows the same rules as Parameter::symbol, with the exception that it can start with numbers.
This label is a short restricted name consisting of only _, a-z, A-Z and 0-9 characters.
*/
const char* getLabel() const override
{
return "info";
return "Info";
}
/**
@@ -55,6 +59,7 @@ protected:
/**
Get the plugin license name (a single line of text).
For commercial plugins this should return some short copyright information.
*/
const char* getLicense() const override
{
@@ -157,6 +162,7 @@ protected:
/**
Get the current value of a parameter.
The host may call this function from any context, including realtime processing.
*/
float getParameterValue(uint32_t index) const override
{
@@ -166,6 +172,9 @@ protected:
/**
Change a parameter value.
The host may call this function from any context, including realtime processing.
When a parameter is marked as automable, you must ensure no non-realtime operations are performed.
@note This function will only be called for parameter inputs.
*/
void setParameterValue(uint32_t, float) override
{
@@ -173,10 +182,11 @@ protected:
}
/* --------------------------------------------------------------------------------------------------------
* Process */
* Audio/MIDI Processing */
/**
Run/process function for plugins without MIDI input.
@note Some parameters might be null if there are no audio inputs or outputs.
*/
void run(const float** inputs, float** outputs, uint32_t frames) override
{
@@ -191,22 +201,51 @@ protected:
if (outputs[1] != inputs[1])
std::memcpy(outputs[1], inputs[1], sizeof(float)*frames);
// set info
fParameters[kParameterBufferSize] = getBufferSize();
// get time position
const TimePosition& timePos(getTimePosition());
// set basic values
fParameters[kParameterTimePlaying] = timePos.playing ? 1.0f : 0.0f;
fParameters[kParameterTimeFrame] = timePos.frame;
fParameters[kParameterTimeValidBBT] = timePos.bbt.valid ? 1.0f : 0.0f;
fParameters[kParameterTimeBar] = timePos.bbt.bar;
fParameters[kParameterTimeBeat] = timePos.bbt.beat;
fParameters[kParameterTimeTick] = timePos.bbt.tick;
fParameters[kParameterTimeBarStartTick] = timePos.bbt.barStartTick;
fParameters[kParameterTimeBeatsPerBar] = timePos.bbt.beatsPerBar;
fParameters[kParameterTimeBeatType] = timePos.bbt.beatType;
fParameters[kParameterTimeTicksPerBeat] = timePos.bbt.ticksPerBeat;
fParameters[kParameterTimeBeatsPerMinute] = timePos.bbt.beatsPerMinute;
// set bbt
if (timePos.bbt.valid)
{
fParameters[kParameterTimeBar] = timePos.bbt.bar;
fParameters[kParameterTimeBeat] = timePos.bbt.beat;
fParameters[kParameterTimeTick] = timePos.bbt.tick;
fParameters[kParameterTimeBarStartTick] = timePos.bbt.barStartTick;
fParameters[kParameterTimeBeatsPerBar] = timePos.bbt.beatsPerBar;
fParameters[kParameterTimeBeatType] = timePos.bbt.beatType;
fParameters[kParameterTimeTicksPerBeat] = timePos.bbt.ticksPerBeat;
fParameters[kParameterTimeBeatsPerMinute] = timePos.bbt.beatsPerMinute;
}
else
{
fParameters[kParameterTimeBar] = 0.0f;
fParameters[kParameterTimeBeat] = 0.0f;
fParameters[kParameterTimeTick] = 0.0f;
fParameters[kParameterTimeBarStartTick] = 0.0f;
fParameters[kParameterTimeBeatsPerBar] = 0.0f;
fParameters[kParameterTimeBeatType] = 0.0f;
fParameters[kParameterTimeTicksPerBeat] = 0.0f;
fParameters[kParameterTimeBeatsPerMinute] = 0.0f;
}
}
/* --------------------------------------------------------------------------------------------------------
* Callbacks (optional) */
/**
Optional callback to inform the plugin about a buffer size change.@
This function will only be called when the plugin is deactivated.
@note This value is only a hint!
Hosts might call run() with a higher or lower number of frames.
*/
void bufferSizeChanged(uint32_t newBufferSize) override
{
fParameters[kParameterBufferSize] = newBufferSize;
}
// -------------------------------------------------------------------------------------------------------
@@ -218,7 +257,7 @@ private:
/**
Set our plugin class as non-copyable and add a leak detector just in case.
*/
DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(ExamplePluginInfo)
DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(InfoExamplePlugin)
};
/* ------------------------------------------------------------------------------------------------------------
@@ -226,7 +265,7 @@ private:
Plugin* createPlugin()
{
return new ExamplePluginInfo();
return new InfoExamplePlugin();
}
// -----------------------------------------------------------------------------------------------------------


+ 15
- 12
plugins/Info/ExampleUIInfo.cpp View File

@@ -1,6 +1,6 @@
/*
* DISTRHO Plugin Framework (DPF)
* Copyright (C) 2012-2014 Filipe Coelho <falktx@falktx.com>
* Copyright (C) 2012-2015 Filipe Coelho <falktx@falktx.com>
*
* Permission to use, copy, modify, and/or distribute this software for any purpose with
* or without fee is hereby granted, provided that the above copyright notice and this
@@ -22,10 +22,10 @@ START_NAMESPACE_DISTRHO

// -----------------------------------------------------------------------------------------------------------

class ExampleUIInfo : public UI
class InfoExampleUI : public UI
{
public:
ExampleUIInfo()
InfoExampleUI()
: UI(405, 256)
{
std::memset(fParameters, 0, sizeof(float)*kParameterCount);
@@ -55,7 +55,7 @@ protected:
/**
Optional callback to inform the UI about a sample rate change on the plugin side.
*/
void sampleRateChanged(double newSampleRate)
void sampleRateChanged(double newSampleRate) override
{
fSampleRate = newSampleRate;
repaint();
@@ -155,11 +155,13 @@ private:
float fParameters[kParameterCount];
double fSampleRate;

// font
FontId fFont;

// temp buf for text
char fStrBuf[0xff+1];

// helpers for putting text into fStrBuf and returning it
const char* getTextBufInt(const int value)
{
std::snprintf(fStrBuf, 0xff, "%i", value);
@@ -182,28 +184,29 @@ private:
return fStrBuf;
}

// helpers for drawing text
void drawLeft(const float x, const float y, const char* const text)
{
beginPath();
fillColor(200,200,200);
textAlign(Align(ALIGN_RIGHT|ALIGN_TOP));
textBox(x, y, 100, text, nullptr);
fillColor(200, 200, 200);
textAlign(ALIGN_RIGHT|ALIGN_TOP);
textBox(x, y, 100, text);
closePath();
}

void drawRight(const float x, const float y, const char* const text)
{
beginPath();
fillColor(255,255,255);
textAlign(Align(ALIGN_LEFT|ALIGN_TOP));
textBox(x+105, y, 100, text, nullptr);
fillColor(255, 255, 255);
textAlign(ALIGN_LEFT|ALIGN_TOP);
textBox(x+105, y, 100, text);
closePath();
}

/**
Set our UI class as non-copyable and add a leak detector just in case.
*/
DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(ExampleUIInfo)
DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(InfoExampleUI)
};

/* ------------------------------------------------------------------------------------------------------------
@@ -211,7 +214,7 @@ private:

UI* createUI()
{
return new ExampleUIInfo();
return new InfoExampleUI();
}

// -----------------------------------------------------------------------------------------------------------


+ 6
- 4
plugins/Info/README.md View File

@@ -1,8 +1,10 @@
# Information example

This example will show how to get several times of information using DPF.<br/>
The plugin will not do any audio processing.<br/>
This example will show how to get some basic information sent to the UI.<br/>

In this example the Plugin will have a lot of parameter outputs which the UI uses to get info from.<br/>
This includes buffer-size and time position. Sample-rate can be access directly from the UI.<br/>
The Plugin has a lot of parameter outputs which the UI uses to get info from.<br/>
This includes buffer-size and time position.<br/>
Sample-rate can be requested directly from the UI.<br/>
The UI will show this information as text.<br/>

The plugin will not do any audio processing.<br/>

Loading…
Cancel
Save