f@0: #pragma once f@0: f@0: #include "cinder/Area.h" f@0: f@0: class DrawInfo f@0: { f@0: public: f@0: f@0: DrawInfo( size_t waveIndex ): f@0: mWaveIndex( waveIndex ), f@0: mWindowWidth(0), f@0: mWindowHeight(0), f@0: mSelectionBarHeight(0), f@0: mShrinkFactor(1) f@0: {} f@0: f@0: void reset( const ci::Area &bounds, float shrinkFactor ) f@0: { f@0: mWindowWidth = bounds.getWidth(); f@0: mWindowHeight = bounds.getHeight(); f@0: mSelectionBarHeight = mWindowHeight / NUM_WAVES; f@0: mShrinkFactor = shrinkFactor; f@0: } f@0: f@0: float audioToHeigt(float audioSample) const { f@0: /* clip into range [-1.1] */ f@0: if (audioSample < -1.0f) { f@0: audioSample = -1.0f; f@0: } f@0: else if ( audioSample > 1.0f ){ f@0: audioSample = 1.0f; f@0: } f@0: f@0: /* map from [-1,1] to [0,1] */ f@0: float ratio = (audioSample - (-1.0f)) * 0.5f; // 2 = 1 - (-1) f@0: f@0: /* get bottom and add the scaled height */ f@0: return ratio * mSelectionBarHeight; //remove bounds.getY1() bound only needed for size of tier f@0: } f@0: f@0: float getMaxChunkHeight() const f@0: { f@0: return mSelectionBarHeight * mShrinkFactor; f@0: } f@0: f@0: float getSelectionBarHeight() const f@0: { f@0: return mSelectionBarHeight; f@0: } f@0: f@0: int32_t getWaveCenterY() const f@0: { f@0: if ( mWaveIndex == 0 ) f@0: return mWindowHeight * 0.75f + 1; f@0: else f@0: return mWindowHeight / (NUM_WAVES * 2); f@0: } f@0: f@0: int flipY(int y) const f@0: { f@0: if ( mWaveIndex == 0) f@0: return mWindowHeight - y /*+ 24*/; f@0: else f@0: return y /*- 24*/; f@0: } f@0: f@0: int flipX(int x) const f@0: { f@0: return x; f@0: } f@0: f@0: f@0: // how much the wave is shrunk on the y axis with respect to the wave's tier f@0: float getShrinkFactor() const f@0: { f@0: return mShrinkFactor; f@0: } f@0: f@0: int32_t getWindowWidth() const f@0: { f@0: return mWindowWidth; f@0: } f@0: f@0: int32_t getWindowHeight() const f@0: { f@0: return mWindowHeight; f@0: } f@0: f@0: DrawInfo( const DrawInfo &original ) = delete; f@0: DrawInfo & operator=( const DrawInfo &original ) = delete; f@0: f@0: private: f@0: const size_t mWaveIndex; f@0: f@0: int32_t mWindowHeight; f@0: int32_t mWindowWidth; f@0: int32_t mSelectionBarHeight; f@0: f@0: float mShrinkFactor; f@0: f@0: };