btrfs: Attempt to fix GCC2 build.
[haiku.git] / src / apps / mediaplayer / interface / PeakView.h
blob491465799755649eb47ab8f0a4e76bec04f7248f
1 /*
2 * Copyright (C) 1998-1999 Be Incorporated. All rights reseved.
3 * Distributed under the terms of the Be Sample Code license.
5 * Copyright (C) 2001-2008 Stephan Aßmus. All rights reserved.
6 * Distributed under the terms of the MIT license.
7 */
9 /*----------------------------------------------------------
10 PURPOSE:
11 gui class for displaying stereo audio peak level info
13 FEATURES:
14 - uses a bitmap, but not a view accepting one, to redraw
15 without flickering.
16 - can be configured to use it's own message runner instead
17 of the windows current pulse (in case you have text views in
18 the window as well, which use a slow pulse for cursor blinking)
19 - if used with own message runner, refresh delay is configurable
20 - can be used in a dynamic liblayout gui
22 USAGE:
23 To display the peak level of your streaming audio, just
24 calculate the local maximum of both channels within your
25 audio buffer and call SetMax() once for every buffer. The
26 PeakView will take care of the rest.
27 min = 0.0
28 max = 1.0
29 ----------------------------------------------------------*/
30 #ifndef PEAK_VIEW_H
31 #define PEAK_VIEW_H
34 #include <View.h>
36 class BBitmap;
37 class BMessageRunner;
39 class PeakView : public BView {
40 public:
41 PeakView(const char* name,
42 bool useGlobalPulse = true,
43 bool displayLabels = true);
44 virtual ~PeakView();
46 // BView interface
47 virtual void MessageReceived(BMessage* message);
48 virtual void AttachedToWindow();
49 virtual void DetachedFromWindow();
50 virtual void MouseDown(BPoint where);
51 virtual void Draw(BRect area);
52 virtual void FrameResized(float width, float height);
53 virtual void Pulse();
54 virtual BSize MinSize();
56 // PeakView
57 bool IsValid() const;
58 void SetPeakRefreshDelay(bigtime_t delay);
59 void SetPeakNotificationWhat(uint32 what);
61 void SetChannelCount(uint32 count);
62 void SetMax(float max, uint32 channel);
64 private:
65 BRect _BackBitmapFrame() const;
66 void _ResizeBackBitmap(int32 width, int32 channels);
67 void _UpdateBackBitmap();
68 void _RenderSpan(uint8* span, uint32 width,
69 float current, float peak, bool overshot);
70 void _DrawBitmap();
72 private:
73 bool fUseGlobalPulse;
74 bool fDisplayLabels;
75 bool fPeakLocked;
77 bigtime_t fRefreshDelay;
78 BMessageRunner* fPulse;
80 struct ChannelInfo {
81 float current_max;
82 float last_max;
83 bigtime_t last_overshot_time;
86 ChannelInfo* fChannelInfos;
87 uint32 fChannelCount;
88 bool fGotData;
90 BBitmap* fBackBitmap;
91 font_height fFontHeight;
93 uint32 fPeakNotificationWhat;
96 #endif // PEAK_VIEW_H