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.
9 /*----------------------------------------------------------
11 gui class for displaying stereo audio peak level info
14 - uses a bitmap, but not a view accepting one, to redraw
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
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.
29 ----------------------------------------------------------*/
39 class PeakView
: public BView
{
41 PeakView(const char* name
,
42 bool useGlobalPulse
= true,
43 bool displayLabels
= true);
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
);
54 virtual BSize
MinSize();
58 void SetPeakRefreshDelay(bigtime_t delay
);
59 void SetPeakNotificationWhat(uint32 what
);
61 void SetChannelCount(uint32 count
);
62 void SetMax(float max
, uint32 channel
);
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
);
77 bigtime_t fRefreshDelay
;
78 BMessageRunner
* fPulse
;
83 bigtime_t last_overshot_time
;
86 ChannelInfo
* fChannelInfos
;
91 font_height fFontHeight
;
93 uint32 fPeakNotificationWhat
;