ardour
audio_region_test.cc
Go to the documentation of this file.
1 /*
2  Copyright (C) 2012 Paul Davis
3 
4  This program is free software; you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation; either version 2 of the License, or
7  (at your option) any later version.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with this program; if not, write to the Free Software
16  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17 */
18 
19 #include <glibmm/miscutils.h>
20 
21 #include "pbd/compose.h"
23 #include "ardour/source_factory.h"
24 #include "ardour/region.h"
25 #include "ardour/region_factory.h"
26 #include "ardour/sndfilesource.h"
27 #include "ardour/audioregion.h"
28 #include "ardour/audioplaylist.h"
29 #include "audio_region_test.h"
30 #include "test_util.h"
31 
32 using namespace std;
33 using namespace PBD;
34 using namespace ARDOUR;
35 
36 void
38 {
40 
41  std::string const test_wav_path = Glib::build_filename (new_test_output_dir(), "test.wav");
42  _playlist = PlaylistFactory::create (DataType::AUDIO, *_session, "test");
43  _audio_playlist = boost::dynamic_pointer_cast<AudioPlaylist> (_playlist);
44  _source = SourceFactory::createWritable (DataType::AUDIO, *_session, test_wav_path, false, get_test_sample_rate ());
45 
46  /* Write a staircase to the source */
47 
49  assert (s);
50 
51  int const signal_length = 4096;
52 
53  Sample staircase[signal_length];
54  for (int i = 0; i < signal_length; ++i) {
55  staircase[i] = i;
56  }
57 
58  s->write (staircase, signal_length);
59 
60  PropertyList plist;
61  plist.add (Properties::start, 0);
62  plist.add (Properties::length, 100);
63  for (int i = 0; i < 16; ++i) {
64  _r[i] = RegionFactory::create (_source, plist);
65  _ar[i] = boost::dynamic_pointer_cast<AudioRegion> (_r[i]);
66  _ar[i]->set_name (string_compose ("ar%1", i));
67  }
68 }
69 
70 void
72 {
73  _playlist.reset ();
74  _audio_playlist.reset ();
75  _source.reset ();
76  for (int i = 0; i < 16; ++i) {
77  _r[i].reset ();
78  _ar[i].reset ();
79  }
80 
82 }
83 
84 
virtual void tearDown()
shared_ptr< T > dynamic_pointer_cast(shared_ptr< U > const &r)
Definition: shared_ptr.hpp:396
bool set_name(const std::string &str)
Definition: region.cc:417
Definition: Beats.hpp:239
LIBARDOUR_API PBD::PropertyDescriptor< framepos_t > start
Definition: region.cc:63
int get_test_sample_rate()
Definition: test_util.cc:150
float Sample
Definition: types.h:54
Definition: amp.h:29
Definition: debug.h:30
virtual framecnt_t write(Sample *src, framecnt_t cnt)
Definition: audiosource.cc:321
std::string new_test_output_dir(std::string prefix)
Definition: test_util.cc:144
bool add(PropertyBase *prop)
std::string string_compose(const std::string &fmt, const T1 &o1)
Definition: compose.h:208
virtual void setUp()
LIBARDOUR_API PBD::PropertyDescriptor< framecnt_t > length
Definition: region.cc:64