root/branches/new_fx_rack_and_sample_fun/libs/hydrogen/include/hydrogen/sample.h @ 608

Revision 608, 3.9 KB (checked in by wolke, 5 years ago)

little bit more work on sample_editor

Line 
1/*
2 * Hydrogen
3 * Copyright(c) 2002-2008 by Alex >Comix< Cominu [comix@users.sourceforge.net]
4 *
5 * http://www.hydrogen-music.org
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY, without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20 *
21 */
22
23#ifndef SAMPLE_BUFFER_H
24#define SAMPLE_BUFFER_H
25
26#include <string>
27
28#include <hydrogen/globals.h>
29#include <hydrogen/Object.h>
30
31namespace H2Core
32{
33
34/**
35\ingroup H2CORE
36*/
37class Sample : public Object
38{
39public:
40        Sample( unsigned frames,
41                const QString& filename,
42                float* data_L = NULL,
43                float* data_R = NULL,
44                bool sample_is_modified = false,
45                const QString& sample_mode = "normal",
46                unsigned start_frame = -1,
47                unsigned loop_frame = -1,
48                int repeats = -1,
49                unsigned end_frame = -1,
50                unsigned fade_out_startframe = -1,
51                int fade_out_type = -1);
52               
53
54        ~Sample();
55
56        float* get_data_l() {
57                return __data_l;
58        }
59        float* get_data_r() {
60                return __data_r;
61        }
62
63        unsigned get_sample_rate() {
64                return __sample_rate;
65        }
66
67        const QString get_filename() {
68                return __filename;
69        }
70
71
72        /// Returns the bytes number ( 2 channels )
73        unsigned get_size() {
74                return __n_frames * sizeof( float ) * 2;
75        }
76
77        /// Loads a sample from disk
78        static Sample* load( const QString& filename );
79
80        unsigned get_n_frames() {
81                return __n_frames;
82        }
83
84        ///beginn of sample edit
85
86        void set_sample_is_modified( bool is_modified ) {
87                __sample_is_modified = is_modified;
88        }
89        bool get_sample_is_modified() const {
90                return __sample_is_modified;
91        }
92
93        void set_sample_mode( QString sample_mode ) {
94                __sample_mode = sample_mode;
95        }
96        QString get_sample_mode() const {
97                return __sample_mode;
98        }
99
100        void set_start_frame( unsigned start_frame ) {
101                __start_frame = start_frame;
102        }
103        unsigned get_start_frame() const {
104                return __start_frame;
105        }
106
107        void set_loop_frame( unsigned loop_frame ) {
108                 __loop_frame = loop_frame;
109        }
110        unsigned get_loop_frame() const {
111                return __loop_frame;
112        }
113
114        void set_repeats( int repeats ) {
115                __repeats = repeats;
116        }
117        int get_repeats() const {
118                return __repeats;
119        }
120
121        void set_end_frame( unsigned end_frame ) {
122                __end_frame = end_frame;
123        }
124        unsigned get_end_frame() const {
125                return __end_frame;
126        }
127
128        void set_fade_out_startframe( unsigned fade_out_startframe ) {
129                __fade_out_startframe = fade_out_startframe;
130        }
131        unsigned get_fade_out_startframe() const {
132                return __fade_out_startframe;
133        }
134
135        void set_fade_out_type( int fade_out_type ) {
136                __fade_out_type = fade_out_type;
137        }
138        int get_fade_out_type() const {
139                return __fade_out_type;
140        }
141
142
143        void sampleEditProzess( Sample* Sample );
144
145private:
146        float *__data_l;        ///< Left channel data
147        float *__data_r;        ///< Right channel data
148
149        unsigned __sample_rate;         ///< samplerate for this sample
150        QString __filename;             ///< filename associated with this sample
151        unsigned __n_frames;            ///< Total number of frames in this sample.
152        bool __sample_is_modified;      ///< true if sample is modified
153        QString __sample_mode;          ///< loop mode
154        unsigned __start_frame;         ///< start frame
155        unsigned __loop_frame;          ///< beginn of the loop section
156        int __repeats;                  ///< repeats from the loop section
157        unsigned __end_frame;           ///< sample end frame
158        unsigned __fade_out_startframe; ///< start frame for fade out
159        int __fade_out_type;            ///< fade out type 1=lin, 2=log
160
161        //static int __total_used_bytes;
162
163        /// loads a wave file
164        static Sample* load_wave( const QString& filename );
165
166        /// loads a FLAC file
167        static Sample* load_flac( const QString& filename );
168};
169
170};
171
172#endif
Note: See TracBrowser for help on using the browser.