2 ==============================================================================
4 This is an automatically generated file created by the Jucer!
6 Creation date: 1 May 2011 12:07:35pm
8 Be careful when adding custom code to these files, as only the code within
9 the "//[xyz]" and "//[/xyz]" sections will be retained when the file is loaded
14 ------------------------------------------------------------------------------
16 The Jucer is part of the JUCE library - "Jules' Utility Class Extensions"
17 Copyright 2004-6 by Raw Material Software ltd.
19 ==============================================================================
22 //[Headers] You can add your own extra header files here...
25 #include "AudioDemoTabComponent.h"
26 #include "AudioDemoSetupPage.h"
27 #include "AudioDemoPlaybackPage.h"
28 #include "AudioDemoSynthPage.h"
29 #include "AudioDemoLatencyPage.h"
30 #include "AudioDemoRecordPage.h"
33 //[MiscUserDefs] You can add your own user definitions and misc code here...
34 LiveAudioInputDisplayComp::LiveAudioInputDisplayComp()
36 nextSample
= subSample
= 0;
38 zeromem (samples
, sizeof (samples
));
41 startTimer (1000 / 50); // use a timer to keep repainting this component
44 LiveAudioInputDisplayComp::~LiveAudioInputDisplayComp()
48 void LiveAudioInputDisplayComp::paint (Graphics
& g
)
50 g
.fillAll (Colours::black
);
52 g
.setColour (Colours::green
);
53 const float midY
= getHeight() * 0.5f
;
54 int sampleNum
= (nextSample
+ numElementsInArray (samples
) - 1);
56 for (int x
= jmin (getWidth(), numElementsInArray (samples
)); --x
>= 0;)
58 const float sampleSize
= midY
* samples
[sampleNum
-- % numElementsInArray (samples
)];
59 g
.drawVerticalLine (x
, midY
- sampleSize
, midY
+ sampleSize
);
63 void LiveAudioInputDisplayComp::timerCallback()
68 void LiveAudioInputDisplayComp::audioDeviceAboutToStart (AudioIODevice
*)
70 zeromem (samples
, sizeof (samples
));
73 void LiveAudioInputDisplayComp::audioDeviceStopped()
75 zeromem (samples
, sizeof (samples
));
78 void LiveAudioInputDisplayComp::audioDeviceIOCallback (const float** inputChannelData
, int numInputChannels
,
79 float** outputChannelData
, int numOutputChannels
, int numSamples
)
81 for (int i
= 0; i
< numSamples
; ++i
)
83 for (int chan
= 0; chan
< numInputChannels
; ++chan
)
85 if (inputChannelData
[chan
] != 0)
86 accumulator
+= fabsf (inputChannelData
[chan
][i
]);
89 const int numSubSamples
= 100; // how many input samples go onto one pixel.
90 const float boost
= 10.0f
; // how much to boost the levels to make it more visible.
94 samples
[nextSample
] = accumulator
* boost
/ numSubSamples
;
95 nextSample
= (nextSample
+ 1) % numElementsInArray (samples
);
96 subSample
= numSubSamples
;
105 // We need to clear the output buffers, in case they're full of junk..
106 for (int i
= 0; i
< numOutputChannels
; ++i
)
107 if (outputChannelData
[i
] != 0)
108 zeromem (outputChannelData
[i
], sizeof (float) * numSamples
);
113 //==============================================================================
114 AudioDemoTabComponent::AudioDemoTabComponent ()
115 : tabbedComponent (0)
117 addAndMakeVisible (tabbedComponent
= new TabbedComponent (TabbedButtonBar::TabsAtTop
));
118 tabbedComponent
->setTabBarDepth (30);
119 tabbedComponent
->addTab (L
"Audio Device Setup", Colours::lightgrey
, new AudioDemoSetupPage (deviceManager
), true);
120 tabbedComponent
->addTab (L
"File Playback", Colours::lightgrey
, new AudioDemoPlaybackPage (deviceManager
), true);
121 tabbedComponent
->addTab (L
"Synth Playback", Colours::lightgrey
, new AudioDemoSynthPage (deviceManager
), true);
122 tabbedComponent
->addTab (L
"Latency Test", Colours::lightgrey
, new AudioDemoLatencyPage (deviceManager
), true);
123 tabbedComponent
->addTab (L
"Recording", Colours::lightgrey
, new AudioDemoRecordPage (deviceManager
), true);
124 tabbedComponent
->setCurrentTabIndex (0);
128 deviceManager
.initialise (2, 2, 0, true, String::empty
, 0);
134 //[Constructor] You can add your own custom stuff here..
138 AudioDemoTabComponent::~AudioDemoTabComponent()
140 //[Destructor_pre]. You can add your own custom destruction code here..
143 deleteAndZero (tabbedComponent
);
146 //[Destructor]. You can add your own custom destruction code here..
150 //==============================================================================
151 void AudioDemoTabComponent::paint (Graphics
& g
)
153 //[UserPrePaint] Add your own custom painting code here..
156 g
.fillAll (Colours::white
);
158 //[UserPaint] Add your own custom painting code here..
162 void AudioDemoTabComponent::resized()
164 tabbedComponent
->setBounds (0, 0, getWidth() - 0, getHeight() - 0);
165 //[UserResized] Add your own custom resize handling here..
171 //[MiscUserCode] You can add your own definitions of your custom methods or any other code here...
172 //==============================================================================
173 Component
* createAudioDemo()
175 return new AudioDemoTabComponent();
181 //==============================================================================
183 /* -- Jucer information section --
185 This is where the Jucer puts all of its metadata, so don't change anything in here!
189 <JUCER_COMPONENT documentType="Component" className="AudioDemoTabComponent" componentName=""
190 parentClasses="public Component" constructorParams="" variableInitialisers=""
191 snapPixels="8" snapActive="1" snapShown="1" overlayOpacity="0.330000013"
192 fixedSize="0" initialWidth="600" initialHeight="400">
193 <BACKGROUND backgroundColour="ffffffff"/>
194 <TABBEDCOMPONENT name="new tabbed component" id="83c980d7793cdced" memberName="tabbedComponent"
195 virtualName="" explicitFocusOrder="0" pos="0 0 0M 0M" orientation="top"
196 tabBarDepth="30" initialTab="0">
197 <TAB name="Audio Device Setup" colour="ffd3d3d3" useJucerComp="1"
198 contentClassName="" constructorParams="deviceManager" jucerComponentFile="AudioDemoSetupPage.cpp"/>
199 <TAB name="File Playback" colour="ffd3d3d3" useJucerComp="1" contentClassName=""
200 constructorParams="deviceManager" jucerComponentFile="AudioDemoPlaybackPage.cpp"/>
201 <TAB name="Synth Playback" colour="ffd3d3d3" useJucerComp="1" contentClassName=""
202 constructorParams="deviceManager" jucerComponentFile="AudioDemoSynthPage.cpp"/>
203 <TAB name="Latency Test" colour="ffd3d3d3" useJucerComp="1" contentClassName=""
204 constructorParams="deviceManager" jucerComponentFile="AudioDemoLatencyPage.cpp"/>
205 <TAB name="Recording" colour="ffd3d3d3" useJucerComp="1" contentClassName=""
206 constructorParams="deviceManager" jucerComponentFile="AudioDemoRecordPage.cpp"/>