[8a7247]: libkwave / Stripe.h Maximize Restore History

Download this file

Stripe.h    88 lines (69 with data), 2.6 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/***************************************************************************
Stripe.h - continuous block of samples
-------------------
begin : Feb 09 2001
copyright : (C) 2001 by Thomas Eschenbacher
email : Thomas Eschenbacher <thomas.eschenbacher@gmx.de>
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef _STRIPE_H_
#define _STRIPE_H_
#include <qarray.h>
#include "mt/Mutex.h"
#include "libkwave/Sample.h"
//***************************************************************************
class Stripe
{
public:
/**
* Default constructor. Creates an empty stripe with zero-length.
*/
Stripe();
/**
* Constructor. Creates a stripe with specified length.
* @param length number of samples
*/
Stripe(unsigned int length);
/**
* Constructor. Creates a stripe that already contains samples.
* @param samples array with initial samples
*/
Stripe(const QArray<sample_t> &samples);
/**
* Returns a reference to alock for the whole stripe.
*/
Mutex &mutex();
/**
* Returns the current length of the stripe in samples.
*/
unsigned int length();
/**
* Resizes the stripe to a new number of samples. If the array
* size is reduced, samples from the end are thrown away. If
* the size is increased, samples with zero value will be added
* to the end.
* @param length new length of the array [samples]
* @return new length [samples]
*/
unsigned int resize(unsigned int length);
/**
* Operator for appending a number of samples to the
* end of the stripe.
*/
void operator << (const QArray<sample_t> &samples);
private:
/** lock for the whole stripe */
Mutex m_lock;
/** array with sample values */
QArray<sample_t> m_samples;
/** mutex for array of samples */
Mutex m_lock_samples;
};
#endif /* _STRIPE_H_ */