xref: /haiku/src/apps/soundrecorder/VUView.h (revision 84011d23949401f654dfb1a4d2a58a543157013c)
1 /*
2  * Copyright 2005, Jérôme Duval. All rights reserved.
3  * Distributed under the terms of the MIT License.
4  *
5  * Inspired by SoundCapture from Be newsletter (Media Kit Basics:
6  *	Consumers and Producers)
7  */
8 
9 #ifndef VUVIEW_H
10 #define VUVIEW_H
11 
12 #include <Bitmap.h>
13 #include <View.h>
14 
15 
16 class VUView : public BView
17 {
18 public:
19 	VUView(BRect rect, uint32 resizeFlags);
20 	~VUView();
21 	void AttachedToWindow();
22 	void DetachedFromWindow();
23 	void Draw(BRect updateRect);
24 	void ComputeLevels(const void* data, size_t size, uint32 format);
25 
26 private:
27 	void _Run();
28 	void _Quit();
29 	static int32 _RenderLaunch(void *data);
30 	void _RenderLoop();
31 	template<typename T> T _ComputeNextLevel(const void *data,
32 		size_t size, uint32 format, int32 channel);
33 
34 	thread_id fThreadId;
35 	BBitmap *fBitmap;
36 	BView *fBitmapView;
37 	bool fQuitting;
38 	int32 fLevelCount;
39 	int32 *fCurrentLevels;
40 	int32 fChannels;
41 };
42 
43 #endif	/* VUVIEW_H */
44