-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMainContentComponent.h
More file actions
84 lines (65 loc) · 2.27 KB
/
MainContentComponent.h
File metadata and controls
84 lines (65 loc) · 2.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#pragma once
#include <JuceHeader.h>
#include <iostream>
#include <cstdio>
#include <cstdint>
#include "stdlib.h"
#include "stdio.h"
#include <readerwriterqueue.h>
#include <thread>
#include "AppState.h"
#include "BigBuffer.h"
#include "WaveformRendering.h"
#include "ServiceLocator.h"
//==============================================================================
class MainContentComponent : public juce::AudioAppComponent
{
public:
//==============================================================================
MainContentComponent() : audioFormatManager(),
waveformGL(*ServiceLocator::getService<BigBuffer>())
{
addAndMakeVisible(waveformGL);
setSize(1000, 150);
setAudioChannels(2, 2);
audioFormatManager.registerBasicFormats();
}
~MainContentComponent() override
{
shutdownAudio();
}
void prepareToPlay(int numChannels, double sampleRate) override
{
waveformGL.prepareToPlay(numChannels, sampleRate);
}
void getNextAudioBlock(const juce::AudioSourceChannelInfo &bufferToFill) override
{
auto *device = deviceManager.getCurrentAudioDevice();
auto activeInputChannels = device->getActiveInputChannels();
auto activeOutputChannels = device->getActiveOutputChannels();
auto maxInputChannels = activeInputChannels.getHighestBit() + 1;
auto maxOutputChannels = activeOutputChannels.getHighestBit() + 1;
int lastNumSamples = 0;
int sample = 0;
// silence the audio
for (auto channel = 0; channel < maxOutputChannels; ++channel)
{
bufferToFill.buffer->clear(channel, bufferToFill.startSample, bufferToFill.numSamples);
}
}
void releaseResources() override {}
void resized() override
{
auto waveformBounds = getLocalBounds();
waveformGL.setBounds(waveformBounds);
}
void paint(juce::Graphics &g) override
{
g.fillAll(Colours::darkgrey);
g.setColour(Colours::whitesmoke);
}
WaveformRendering waveformGL;
private:
AudioFormatManager audioFormatManager;
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(MainContentComponent)
};