- Library code update

- project update (added Eigen)

git-svn-id: http://moon:8086/svn/software/trunk/projects/mpsk_rx_gui@94 b431acfa-c32f-4a4a-93f1-934dc6c82436
This commit is contained in:
2014-12-20 20:59:48 +00:00
parent 1b4d8e9f54
commit dc5560392f
312 changed files with 6349 additions and 4195 deletions
@@ -75,11 +75,10 @@ class AudioDeviceSelectorComponent::MidiInputSelectorComponentListBox : public
private ListBoxModel
{
public:
MidiInputSelectorComponentListBox (AudioDeviceManager& dm,
const String& noItemsMessage_)
MidiInputSelectorComponentListBox (AudioDeviceManager& dm, const String& noItems)
: ListBox (String::empty, nullptr),
deviceManager (dm),
noItemsMessage (noItemsMessage_)
noItemsMessage (noItems)
{
items = MidiInput::getDevices();
@@ -87,15 +86,12 @@ public:
setOutlineThickness (1);
}
int getNumRows()
int getNumRows() override
{
return items.size();
}
void paintListBoxItem (int row,
Graphics& g,
int width, int height,
bool rowIsSelected)
void paintListBoxItem (int row, Graphics& g, int width, int height, bool rowIsSelected) override
{
if (isPositiveAndBelow (row, items.size()))
{
@@ -118,7 +114,7 @@ public:
}
}
void listBoxItemClicked (int row, const MouseEvent& e)
void listBoxItemClicked (int row, const MouseEvent& e) override
{
selectRow (row);
@@ -126,12 +122,12 @@ public:
flipEnablement (row);
}
void listBoxItemDoubleClicked (int row, const MouseEvent&)
void listBoxItemDoubleClicked (int row, const MouseEvent&) override
{
flipEnablement (row);
}
void returnKeyPressed (int row)
void returnKeyPressed (int row) override
{
flipEnablement (row);
}
@@ -214,7 +210,6 @@ public:
type.scanForDevices();
setup.manager->addChangeListener (this);
updateAllControls();
}
~AudioDeviceSettingsPanel()
@@ -224,83 +219,107 @@ public:
void resized() override
{
const int lx = proportionOfWidth (0.35f);
const int w = proportionOfWidth (0.4f);
const int h = 24;
const int space = 6;
const int dh = h + space;
int y = 0;
if (outputDeviceDropDown != nullptr)
if (AudioDeviceSelectorComponent* parent = findParentComponentOfClass<AudioDeviceSelectorComponent>())
{
outputDeviceDropDown->setBounds (lx, y, w, h);
Rectangle<int> r (proportionOfWidth (0.35f), 0, proportionOfWidth (0.6f), 3000);
if (testButton != nullptr)
testButton->setBounds (proportionOfWidth (0.77f),
outputDeviceDropDown->getY(),
proportionOfWidth (0.18f),
h);
y += dh;
const int maxListBoxHeight = 100;
const int h = parent->getItemHeight();
const int space = h / 4;
if (outputDeviceDropDown != nullptr)
{
Rectangle<int> row (r.removeFromTop (h));
if (testButton != nullptr)
{
testButton->changeWidthToFitText (h);
testButton->setBounds (row.removeFromRight (testButton->getWidth()));
row.removeFromRight (space);
}
outputDeviceDropDown->setBounds (row);
r.removeFromTop (space);
}
if (inputDeviceDropDown != nullptr)
{
Rectangle<int> row (r.removeFromTop (h));
inputLevelMeter->setBounds (row.removeFromRight (testButton != nullptr ? testButton->getWidth() : row.getWidth() / 6));
row.removeFromRight (space);
inputDeviceDropDown->setBounds (row);
r.removeFromTop (space);
}
if (outputChanList != nullptr)
{
outputChanList->setBounds (r.removeFromTop (outputChanList->getBestHeight (maxListBoxHeight)));
outputChanLabel->setBounds (0, outputChanList->getBounds().getCentreY() - h / 2, r.getX(), h);
r.removeFromTop (space);
}
if (inputChanList != nullptr)
{
inputChanList->setBounds (r.removeFromTop (inputChanList->getBestHeight (maxListBoxHeight)));
inputChanLabel->setBounds (0, inputChanList->getBounds().getCentreY() - h / 2, r.getX(), h);
r.removeFromTop (space);
}
r.removeFromTop (space * 2);
if (showAdvancedSettingsButton != nullptr)
{
showAdvancedSettingsButton->setBounds (r.withHeight (h));
showAdvancedSettingsButton->changeWidthToFitText();
}
const bool advancedSettingsVisible = showAdvancedSettingsButton == nullptr
|| ! showAdvancedSettingsButton->isVisible();
if (sampleRateDropDown != nullptr)
{
sampleRateDropDown->setVisible (advancedSettingsVisible);
sampleRateDropDown->setBounds (r.removeFromTop (h));
r.removeFromTop (space);
}
if (bufferSizeDropDown != nullptr)
{
bufferSizeDropDown->setVisible (advancedSettingsVisible);
bufferSizeDropDown->setBounds (r.removeFromTop (h));
r.removeFromTop (space);
}
r.removeFromTop (space);
if (showUIButton != nullptr || resetDeviceButton != nullptr)
{
Rectangle<int> buttons (r.removeFromTop (h));
if (showUIButton != nullptr)
{
showUIButton->setVisible (advancedSettingsVisible);
showUIButton->changeWidthToFitText (h);
showUIButton->setBounds (buttons.removeFromLeft (showUIButton->getWidth()));
buttons.removeFromLeft (space);
}
if (resetDeviceButton != nullptr)
{
resetDeviceButton->setVisible (advancedSettingsVisible);
resetDeviceButton->changeWidthToFitText (h);
resetDeviceButton->setBounds (buttons.removeFromLeft (resetDeviceButton->getWidth()));
}
r.removeFromTop (space);
}
setSize (getWidth(), r.getY());
}
if (inputDeviceDropDown != nullptr)
else
{
inputDeviceDropDown->setBounds (lx, y, w, h);
inputLevelMeter->setBounds (proportionOfWidth (0.77f),
inputDeviceDropDown->getY(),
proportionOfWidth (0.18f),
h);
y += dh;
}
const int maxBoxHeight = 100;
if (outputChanList != nullptr)
{
const int bh = outputChanList->getBestHeight (maxBoxHeight);
outputChanList->setBounds (lx, y, proportionOfWidth (0.55f), bh);
y += bh + space;
}
if (inputChanList != nullptr)
{
const int bh = inputChanList->getBestHeight (maxBoxHeight);
inputChanList->setBounds (lx, y, proportionOfWidth (0.55f), bh);
y += bh + space;
}
y += space * 2;
if (showAdvancedSettingsButton != nullptr)
{
showAdvancedSettingsButton->changeWidthToFitText (h);
showAdvancedSettingsButton->setTopLeftPosition (lx, y);
}
if (sampleRateDropDown != nullptr)
{
sampleRateDropDown->setVisible (showAdvancedSettingsButton == nullptr
|| ! showAdvancedSettingsButton->isVisible());
sampleRateDropDown->setBounds (lx, y, w, h);
y += dh;
}
if (bufferSizeDropDown != nullptr)
{
bufferSizeDropDown->setVisible (showAdvancedSettingsButton == nullptr
|| ! showAdvancedSettingsButton->isVisible());
bufferSizeDropDown->setBounds (lx, y, w, h);
y += dh;
}
if (showUIButton != nullptr)
{
showUIButton->setVisible (showAdvancedSettingsButton == nullptr
|| ! showAdvancedSettingsButton->isVisible());
showUIButton->changeWidthToFitText (h);
showUIButton->setTopLeftPosition (lx, y);
jassertfalse;
}
}
@@ -398,6 +417,10 @@ public:
{
setup.manager->playTestSound();
}
else if (button == resetDeviceButton)
{
resetDevice();
}
}
void updateAllControls()
@@ -406,6 +429,7 @@ public:
updateInputsComboBox();
updateControlPanelButton();
updateResetButton();
if (AudioIODevice* const currentDevice = setup.manager->getCurrentAudioDevice())
{
@@ -418,6 +442,7 @@ public:
= new ChannelSelectorListBox (setup, ChannelSelectorListBox::audioOutputType,
TRANS ("(no audio output channels found)")));
outputChanLabel = new Label (String::empty, TRANS("Active output channels:"));
outputChanLabel->setJustificationType (Justification::centredRight);
outputChanLabel->attachToComponent (outputChanList, true);
}
@@ -438,6 +463,7 @@ public:
= new ChannelSelectorListBox (setup, ChannelSelectorListBox::audioInputType,
TRANS("(no audio input channels found)")));
inputChanLabel = new Label (String::empty, TRANS("Active input channels:"));
inputChanLabel->setJustificationType (Justification::centredRight);
inputChanLabel->attachToComponent (inputChanList, true);
}
@@ -468,6 +494,7 @@ public:
inputDeviceDropDown->setSelectedId (-1, dontSendNotification);
}
sendLookAndFeelChange();
resized();
setSize (getWidth(), getLowestY() + 4);
}
@@ -477,6 +504,12 @@ public:
updateAllControls();
}
void resetDevice()
{
setup.manager->closeAudioDevice();
setup.manager->restartLastAudioDevice();
}
private:
AudioIODeviceType& type;
const AudioDeviceSetupDetails setup;
@@ -485,7 +518,7 @@ private:
ScopedPointer<Label> outputDeviceLabel, inputDeviceLabel, sampleRateLabel, bufferSizeLabel, inputChanLabel, outputChanLabel;
ScopedPointer<TextButton> testButton;
ScopedPointer<Component> inputLevelMeter;
ScopedPointer<TextButton> showUIButton, showAdvancedSettingsButton;
ScopedPointer<TextButton> showUIButton, showAdvancedSettingsButton, resetDeviceButton;
void showCorrectDeviceName (ComboBox* const box, const bool isInput)
{
@@ -532,7 +565,7 @@ private:
if (currentDevice != nullptr && currentDevice->hasControlPanel())
{
addAndMakeVisible (showUIButton = new TextButton (TRANS ("Show this device's control panel"),
addAndMakeVisible (showUIButton = new TextButton (TRANS ("Control panel"),
TRANS ("Opens the device's own control panel")));
showUIButton->addListener (this);
}
@@ -540,6 +573,28 @@ private:
resized();
}
void updateResetButton()
{
if (AudioIODevice* const currentDevice = setup.manager->getCurrentAudioDevice())
{
if (currentDevice->hasControlPanel())
{
if (resetDeviceButton == nullptr)
{
addAndMakeVisible (resetDeviceButton = new TextButton (TRANS ("Reset device"),
TRANS ("Resets the audio interface - sometimes needed after changing a device's properties in its custom control panel")));
resetDeviceButton->addListener (this);
resized();
}
return;
}
}
resetDeviceButton = nullptr;
}
void updateOutputsComboBox()
{
if (setup.maxNumOutputChannels > 0 || ! type.hasSeparateInputsAndOutputs())
@@ -557,7 +612,8 @@ private:
if (setup.maxNumOutputChannels > 0)
{
addAndMakeVisible (testButton = new TextButton (TRANS("Test")));
addAndMakeVisible (testButton = new TextButton (TRANS("Test"),
TRANS("Plays a test tone")));
testButton->addListener (this);
}
}
@@ -918,6 +974,7 @@ AudioDeviceSelectorComponent::AudioDeviceSelectorComponent (AudioDeviceManager&
const bool showChannelsAsStereoPairs_,
const bool hideAdvancedOptionsWithButton_)
: deviceManager (dm),
itemHeight (24),
minOutputChannels (minOutputChannels_),
maxOutputChannels (maxOutputChannels_),
minInputChannels (minInputChannels_),
@@ -984,42 +1041,40 @@ AudioDeviceSelectorComponent::~AudioDeviceSelectorComponent()
deviceManager.removeChangeListener (this);
}
void AudioDeviceSelectorComponent::setItemHeight (int newItemHeight)
{
itemHeight = newItemHeight;
resized();
}
void AudioDeviceSelectorComponent::resized()
{
const int lx = proportionOfWidth (0.35f);
const int w = proportionOfWidth (0.4f);
const int h = 24;
const int space = 6;
const int dh = h + space;
int y = 15;
Rectangle<int> r (proportionOfWidth (0.35f), 15, proportionOfWidth (0.6f), 3000);
const int space = itemHeight / 4;
if (deviceTypeDropDown != nullptr)
{
deviceTypeDropDown->setBounds (lx, y, proportionOfWidth (0.3f), h);
y += dh + space * 2;
deviceTypeDropDown->setBounds (r.removeFromTop (itemHeight));
r.removeFromTop (space * 3);
}
if (audioDeviceSettingsComp != nullptr)
{
audioDeviceSettingsComp->setBounds (0, y, getWidth(), audioDeviceSettingsComp->getHeight());
y += audioDeviceSettingsComp->getHeight() + space;
audioDeviceSettingsComp->resized();
audioDeviceSettingsComp->setBounds (r.removeFromTop (audioDeviceSettingsComp->getHeight())
.withX (0).withWidth (getWidth()));
r.removeFromTop (space);
}
if (midiInputsList != nullptr)
{
const int bh = midiInputsList->getBestHeight (jmin (h * 8, getHeight() - y - space - h));
midiInputsList->setBounds (lx, y, w, bh);
y += bh + space;
midiInputsList->setBounds (r.removeFromTop (midiInputsList->getBestHeight (jmin (itemHeight * 8,
getHeight() - r.getY() - space - itemHeight))));
r.removeFromTop (space);
}
if (midiOutputSelector != nullptr)
midiOutputSelector->setBounds (lx, y, w, h);
}
void AudioDeviceSelectorComponent::childBoundsChanged (Component* child)
{
if (child == audioDeviceSettingsComp)
resized();
midiOutputSelector->setBounds (r.removeFromTop (itemHeight));
}
void AudioDeviceSelectorComponent::comboBoxChanged (ComboBox* comboBoxThatHasChanged)
@@ -1069,13 +1124,10 @@ void AudioDeviceSelectorComponent::updateAllControls()
details.maxNumOutputChannels = maxOutputChannels;
details.useStereoPairs = showChannelsAsStereoPairs;
audioDeviceSettingsComp = new AudioDeviceSettingsPanel (*type, details, hideAdvancedOptionsWithButton);
if (audioDeviceSettingsComp != nullptr)
{
addAndMakeVisible (audioDeviceSettingsComp);
audioDeviceSettingsComp->resized();
}
AudioDeviceSettingsPanel* sp = new AudioDeviceSettingsPanel (*type, details, hideAdvancedOptionsWithButton);
audioDeviceSettingsComp = sp;
addAndMakeVisible (sp);
sp->updateAllControls();
}
}
@@ -75,11 +75,15 @@ public:
/** The device manager that this component is controlling */
AudioDeviceManager& deviceManager;
/** Sets the standard height used for items in the panel. */
void setItemHeight (int itemHeight);
/** Returns the standard height used for items in the panel. */
int getItemHeight() const noexcept { return itemHeight; }
//==============================================================================
/** @internal */
void resized() override;
/** @internal */
void childBoundsChanged (Component*) override;
private:
//==============================================================================
@@ -87,6 +91,7 @@ private:
ScopedPointer<Label> deviceTypeDropDownLabel;
ScopedPointer<Component> audioDeviceSettingsComp;
String audioDeviceSettingsCompType;
int itemHeight;
const int minOutputChannels, maxOutputChannels, minInputChannels, maxInputChannels;
const bool showChannelsAsStereoPairs;
const bool hideAdvancedOptionsWithButton;
@@ -39,10 +39,10 @@ struct AudioThumbnail::MinMaxValue
inline char getMinValue() const noexcept { return values[0]; }
inline char getMaxValue() const noexcept { return values[1]; }
inline void setFloat (const float newMin, const float newMax) noexcept
inline void setFloat (Range<float> newRange) noexcept
{
values[0] = (char) jlimit (-128, 127, roundFloatToInt (newMin * 127.0f));
values[1] = (char) jlimit (-128, 127, roundFloatToInt (newMax * 127.0f));
values[0] = (char) jlimit (-128, 127, roundFloatToInt (newRange.getStart() * 127.0f));
values[1] = (char) jlimit (-128, 127, roundFloatToInt (newRange.getEnd() * 127.0f));
if (values[0] == values[1])
{
@@ -115,7 +115,7 @@ public:
}
}
void getLevels (int64 startSample, int numSamples, Array<float>& levels)
void getLevels (int64 startSample, int numSamples, Array<Range<float> >& levels)
{
const ScopedLock sl (readerLock);
@@ -132,11 +132,10 @@ public:
if (reader != nullptr)
{
float l[4] = { 0 };
reader->readMaxLevels (startSample, numSamples, l[0], l[1], l[2], l[3]);
if (levels.size() < (int) reader->numChannels)
levels.insertMultiple (0, Range<float>(), (int) (reader->numChannels - levels.size()));
levels.clearQuick();
levels.addArray ((const float*) l, 4);
reader->readMaxLevels (startSample, numSamples, levels.getRawDataPointer(), (int) reader->numChannels);
lastReaderUseTime = Time::getMillisecondCounter();
}
@@ -202,8 +201,8 @@ public:
private:
AudioThumbnail& owner;
ScopedPointer <InputSource> source;
ScopedPointer <AudioFormatReader> reader;
ScopedPointer<InputSource> source;
ScopedPointer<AudioFormatReader> reader;
CriticalSection readerLock;
uint32 lastReaderUseTime;
@@ -230,23 +229,26 @@ private:
const int lastThumbIndex = sampleToThumbSample (startSample + numToDo);
const int numThumbSamps = lastThumbIndex - firstThumbIndex;
HeapBlock<MinMaxValue> levelData ((size_t) numThumbSamps * 2);
MinMaxValue* levels[2] = { levelData, levelData + numThumbSamps };
HeapBlock<MinMaxValue> levelData ((size_t) numThumbSamps * numChannels);
HeapBlock<MinMaxValue*> levels (numChannels);
for (int i = 0; i < (int) numChannels; ++i)
levels[i] = levelData + i * numThumbSamps;
HeapBlock<Range<float> > levelsRead (numChannels);
for (int i = 0; i < numThumbSamps; ++i)
{
float lowestLeft, highestLeft, lowestRight, highestRight;
reader->readMaxLevels ((firstThumbIndex + i) * owner.samplesPerThumbSample,
owner.samplesPerThumbSample, levelsRead, numChannels);
reader->readMaxLevels ((firstThumbIndex + i) * owner.samplesPerThumbSample, owner.samplesPerThumbSample,
lowestLeft, highestLeft, lowestRight, highestRight);
levels[0][i].setFloat (lowestLeft, highestLeft);
levels[1][i].setFloat (lowestRight, highestRight);
for (int j = 0; j < (int) numChannels; ++j)
levels[j][i].setFloat (levelsRead[j]);
}
{
const ScopedUnlock su (readerLock);
owner.setLevels (levels, firstThumbIndex, 2, numThumbSamps);
owner.setLevels (levels, firstThumbIndex, (int) numChannels, numThumbSamps);
}
numSamplesFinished += numToDo;
@@ -342,7 +344,7 @@ public:
}
private:
Array <MinMaxValue> data;
Array<MinMaxValue> data;
int peakLevel;
void ensureSize (const int thumbSamples)
@@ -391,6 +393,7 @@ public:
const MinMaxValue* cacheData = getData (channelNum, clip.getX() - area.getX());
RectangleList<float> waveform;
waveform.ensureStorageAllocated (clip.getWidth());
float x = (float) clip.getX();
@@ -414,7 +417,7 @@ public:
}
private:
Array <MinMaxValue> data;
Array<MinMaxValue> data;
double cachedStart, cachedTimePerPixel;
int numChannelsCached, numSamplesCached;
bool cacheNeedsRefilling;
@@ -451,7 +454,7 @@ private:
if (timePerPixel * rate <= sampsPerThumbSample && levelData != nullptr)
{
int sample = roundToInt (startTime * rate);
Array<float> levels;
Array<Range<float> > levels;
int i;
for (i = 0; i < numSamples; ++i)
@@ -469,11 +472,10 @@ private:
{
levelData->getLevels (sample, jmax (1, nextSample - sample), levels);
const int totalChans = jmin (levels.size() / 2, numChannelsCached);
const int totalChans = jmin (levels.size(), numChannelsCached);
for (int chan = 0; chan < totalChans; ++chan)
getData (chan, i)->setFloat (levels.getUnchecked (chan * 2),
levels.getUnchecked (chan * 2 + 1));
getData (chan, i)->setFloat (levels.getReference (chan));
}
}
@@ -713,8 +715,7 @@ void AudioThumbnail::addBlock (const int64 startSample, const AudioSampleBuffer&
for (int i = 0; i < numToDo; ++i)
{
const int start = i * samplesPerThumbSample;
Range<float> range (FloatVectorOperations::findMinAndMax (sourceData + start, jmin (samplesPerThumbSample, numSamples - start)));
dest[i].setFloat (range.getStart(), range.getEnd());
dest[i].setFloat (FloatVectorOperations::findMinAndMax (sourceData + start, jmin (samplesPerThumbSample, numSamples - start)));
}
}
@@ -816,7 +816,7 @@ void MidiKeyboardComponent::timerCallback()
const Array<MouseInputSource>& mouseSources = Desktop::getInstance().getMouseSources();
for (MouseInputSource* mi = mouseSources.begin(), * const e = mouseSources.end(); mi != e; ++mi)
updateNoteUnderMouse (getLocalPoint (nullptr, mi->getScreenPosition()), mi->isDragging(), mi->getIndex());
updateNoteUnderMouse (getLocalPoint (nullptr, mi->getScreenPosition()).roundToInt(), mi->isDragging(), mi->getIndex());
}
}