13
0
livetrax/gtk2_ardour/tape_region_view.cc

161 lines
10 KiB
C++
Raw Normal View History

/*
Copyright (C) 2006 Paul Davis
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.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <cmath>
#include <algorithm>
#include <gtkmm.h>
#include <gtkmm2ext/gtk_ui.h>
#include "ardour/audioregion.h"
#include "ardour/audiosource.h"
#include "tape_region_view.h"
#include "audio_time_axis.h"
#include "gui_thread.h"
#include "pbd/i18n.h"
using namespace ARDOUR;
Large nasty commit in the form of a 5000 line patch chock-full of completely unecessary changes. (Sorry, doing a "sprint" based thing, this is the end of the first one) Achieved MIDI track and bus creation, associated Jack port and diskstream creation, and minimal GUI stuff for creating them. Should be set to start work on actually recording and playing midi to/from disk now. Relevant (significant) changes: - Creation of a Buffer class. Base class is type agnostic so things can point to a buffer but not care what kind it is (otherwise it'd be a template). Derived into AudioBuffer and MidiBuffer, with a type tag because checking type is necessary in parts of the code where dynamic_cast wouldn't be wise. Originally I considered this a hack, but passing around a type proved to be a very good solution to all the other problems (below). There is a 1:1 mapping between jack port data types and ardour Buffer types (with a conversion function), but that's easily removed if it ever becomes necessary. Having the type scoped in the Buffer class is maybe not the best spot for it, but whatever (this is proof of concept kinda stuff right now...) - IO now has a "default" port type (passed to the constructor and stored as a member), used by ensure_io (and similar) to create n ports. IO::register_***_port has a type argument that defaults to the default type if not passed. Rationale: previous IO API is identical, no changes needed to existing code, but path is paved for multiple port types in one IO, which we will need for eg synth plugin inserts, among other things. This is not quite ideal (best would be to only have the two port register functions and have them take a type), but the alternative is a lot of work (namely destroying the 'ensure' functions and everything that uses them) for very little gain. (I am convinced after quite a few tries at the whiteboard that subclassing IO in any way is not a feasible option, look at it's inheritance diagram in Doxygen and you can see why) - AudioEngine::register_audio_input_port is now register_input_port and takes a type argument. Ditto for output. - (Most significant change) AudioDiskstream abstracted into Distream, and sibling MidiDiskstream created. Very much still a work in progress, but Diskstream is there to switch references over to (most already are), which is the important part. It is still unclear what the MIDI diskstream's relation to channels is, but I'm pretty sure they will be single channel only (so SMF Type 0) since noone can come up with a reason otherwise. - MidiTrack creation. Same thing as AudioTrack but with a different default type basically. No big deal here. - Random cleanups and variable renamings etc. because I have OCD and can't help myself. :) Known broken: Loading of sessions containing MIDI tracks. git-svn-id: svn://localhost/ardour2/branches/midi@641 d708f5d6-7413-0410-9779-e7cbd77b26cf
2006-06-26 12:01:34 -04:00
using namespace PBD;
using namespace Editing;
using namespace ArdourCanvas;
const TimeAxisViewItem::Visibility TapeAudioRegionView::default_tape_visibility
= TimeAxisViewItem::Visibility (
TimeAxisViewItem::ShowNameHighlight |
TimeAxisViewItem::ShowNameText |
TimeAxisViewItem::ShowFrame |
TimeAxisViewItem::HideFrameRight |
TimeAxisViewItem::FullWidthNameHighlight);
TapeAudioRegionView::TapeAudioRegionView (ArdourCanvas::Container *parent, RouteTimeAxisView &tv,
boost::shared_ptr<AudioRegion> r,
double spu,
uint32_t basic_color)
: AudioRegionView (parent, tv, r, spu, basic_color, false,
TimeAxisViewItem::Visibility ((r->position() != 0) ? default_tape_visibility :
TimeAxisViewItem::Visibility (default_tape_visibility|TimeAxisViewItem::HideFrameLeft)))
{
}
void
TapeAudioRegionView::init (bool /*wfw*/)
{
/* never wait for data: always just create the waves, connect once and then
we'll update whenever we need to.
*/
AudioRegionView::init (false);
/* every time the wave data changes and peaks are ready, redraw */
for (uint32_t n = 0; n < audio_region()->n_channels(); ++n) {
audio_region()->audio_source(n)->PeaksReady.connect (*this, invalidator (*this), boost::bind (&TapeAudioRegionView::update, this, n), gui_context());
}
}
TapeAudioRegionView::~TapeAudioRegionView()
{
}
void
TapeAudioRegionView::update (uint32_t /*n*/)
{
/* this code doesn't work properly, the WaveViewCache is not updated
* when recording over (replacing) an existing part of the tape.
*
* WaveView probably needs to become aware if the given Region is
* tape-track and handle caching.
*
* explicitly forcing an update here can deadlock if the rendering
* request is non-threaded (resize track height or at rec-stop)
*/
#if 0
/* deadlock:
#1 0x00007f9570ebd77c in g_mutex_lock_slowpath (mutex=0x7f9575157760 <ArdourCanvas::WaveView::current_image_lock>) at ././glib/gthread-posix.c:1313
#2 0x000055f6f8d1aac0 in Glib::Threads::Mutex::Lock::Lock(Glib::Threads::Mutex&) (this=0x7ffc4d905aa0, mutex=...) at /usr/include/glibmm-2.4/glibmm/threads.h:688
#3 0x00007f9574f05054 in ArdourCanvas::WaveView::invalidate_image_cache() (this=0x55f6fdf341a0) at ../libs/canvas/wave_view.cc:275
#4 0x00007f9574f0b1b0 in ArdourCanvas::WaveView::gain_changed() (this=0x55f6fdf341a0) at ../libs/canvas/wave_view.cc:1329
#5 0x000055f6f96eb1b8 in TapeAudioRegionView::update(unsigned int) (this=0x55f6fdf32640) at ../gtk2_ardour/tape_region_view.cc:102
#6 0x000055f6f96eba9f in boost::_mfi::mf1<void, TapeAudioRegionView, unsigned int>::operator()(TapeAudioRegionView*, unsigned int) const (this=0x55f6fa74ce10, p=0x55f6fdf32640, a1=0)
at /usr/include/boost/bind/mem_fn_template.hpp:165
#7 0x000055f6f96eb9b3 in boost::_bi::list2<boost::_bi::value<TapeAudioRegionView*>, boost::_bi::value<unsigned int> >::operator()<boost::_mfi::mf1<void, TapeAudioRegionView, unsigned int>, boost::_bi::list0>(boost::_bi::type<void>, boost::_mfi::mf1<void, TapeAudioRegionView, unsigned int>&, boost::_bi::list0&, int) (this=0x55f6fa74ce20, f=..., a=...)
at /usr/include/boost/bind/bind.hpp:319
#8 0x000055f6f96eb76f in boost::_bi::bind_t<void, boost::_mfi::mf1<void, TapeAudioRegionView, unsigned int>, boost::_bi::list2<boost::_bi::value<TapeAudioRegionView*>, boost::_bi::value<unsigned int> > >::operator()() (this=0x55f6fa74ce10) at /usr/include/boost/bind/bind.hpp:1294
#9 0x000055f6f96eb6b4 in boost::detail::function::void_function_obj_invoker0<boost::_bi::bind_t<void, boost::_mfi::mf1<void, TapeAudioRegionView, unsigned int>, boost::_bi::list2<boost::_bi::value<TapeAudioRegionView*>, boost::_bi::value<unsigned int> > >, void>::invoke(boost::detail::function::function_buffer&) (function_obj_ptr=...)
at /usr/include/boost/function/function_template.hpp:159
#10 0x000055f6f8d73fc8 in boost::function0<void>::operator()() const (this=0x55f6fefe4f60) at /usr/include/boost/function/function_template.hpp:771
#11 0x000055f6f8da3a00 in boost::_bi::list0::operator()<boost::function<void ()>, boost::_bi::list0>(boost::_bi::type<void>, boost::function<void ()>&, boost::_bi::list0&, int) (this=0x55f6fefe4f80, f=...) at /usr/include/boost/bind/bind.hpp:198
#12 0x000055f6f8d9869f in boost::_bi::bind_t<boost::_bi::unspecified, boost::function<void ()>, boost::_bi::list0>::operator()() (this=0x55f6fefe4f60)
at /usr/include/boost/bind/bind.hpp:1294
#13 0x000055f6f8d8f068 in boost::detail::function::void_function_obj_invoker0<boost::_bi::bind_t<boost::_bi::unspecified, boost::function<void ()>, boost::_bi::list0>, void>::invoke(boost::detail::function::function_buffer&) (function_obj_ptr=...) at /usr/include/boost/function/function_template.hpp:159
#14 0x000055f6f8d73fc8 in boost::function0<void>::operator()() const (this=0x7ffc4d905f60) at /usr/include/boost/function/function_template.hpp:771
#15 0x00007f9574b11192 in AbstractUI<Gtkmm2ext::UIRequest>::call_slot(PBD::EventLoop::InvalidationRecord*, boost::function<void ()> const&) (this=
0x55f6fa47dfe0, invalidation=0x55f6fdf375d0, f=...) at /home/rgareus/src/ardour/libs/pbd/pbd/abstract_ui.cc:425
#16 0x000055f6f8d70a9c in PBD::Signal0<void, PBD::OptionalLastValue<void> >::compositor(boost::function<void ()>, PBD::EventLoop*, PBD::EventLoop::InvalidationRecord*) (f=..., event_loop=0x55f6fa47dfe0, ir=0x55f6fdf375d0) at /home/rgareus/src/ardour/build/libs/pbd/pbd/signals_generated.h:216
#17 0x000055f6f8da3c64 in boost::_bi::list3<boost::_bi::value<boost::function<void ()> >, boost::_bi::value<PBD::EventLoop*>, boost::_bi::value<PBD::EventLoop::InvalidationRecord*> >::operator()<void (*)(boost::function<void ()>, PBD::EventLoop*, PBD::EventLoop::InvalidationRecord*), boost::_bi::list0>(boost::_bi::type<void>, void (*&)(boost::function<void ()>, PBD::EventLoop*, PBD::EventLoop::InvalidationRecord*), boost::_bi::list0&, int) (this=0x55f6fa6a9bd8, f=
@0x55f6fa6a9bd0: 0x55f6f8d70a0f <PBD::Signal0<void, PBD::OptionalLastValue<void> >::compositor(boost::function<void ()>, PBD::EventLoop*, PBD::EventLoop::InvalidationRecord*)>, a=...)
at /usr/include/boost/bind/bind.hpp:398
#18 0x000055f6f8d98827 in boost::_bi::bind_t<void, void (*)(boost::function<void ()>, PBD::EventLoop*, PBD::EventLoop::InvalidationRecord*), boost::_bi::list3<boost::_bi::value<boost::function<void ()> >, boost::_bi::value<PBD::EventLoop*>, boost::_bi::value<PBD::EventLoop::InvalidationRecord*> > >::operator()() (this=0x55f6fa6a9bd0) at /usr/include/boost/bind/bind.hpp:1294
#19 0x000055f6f8d8f1ee in boost::detail::function::void_function_obj_invoker0<boost::_bi::bind_t<void, void (*)(boost::function<void ()>, PBD::EventLoop*, PBD::EventLoop::InvalidationRecord*), boost::_bi::list3<boost::_bi::value<boost::function<void ()> >, boost::_bi::value<PBD::EventLoop*>, boost::_bi::value<PBD::EventLoop::InvalidationRecord*> > >, void>::invoke(boost::detail::function::function_buffer&) (function_obj_ptr=...) at /usr/include/boost/function/function_template.hpp:159
#20 0x000055f6f8d73fc8 in boost::function0<void>::operator()() const (this=0x55f6ffdb4de0) at /usr/include/boost/function/function_template.hpp:771
#21 0x000055f6f8d70ea8 in PBD::Signal0<void, PBD::OptionalLastValue<void> >::operator()() (this=0x55f6fd359158) at /home/rgareus/src/ardour/build/libs/pbd/pbd/signals_generated.h:325
#22 0x00007f95739515a3 in ARDOUR::AudioSource::done_with_peakfile_writes(bool) (this=0x55f6fd359140, done=true) at ../libs/ardour/audiosource.cc:841
#23 0x00007f9573950fbe in ARDOUR::AudioSource::build_peaks_from_scratch() (this=0x55f6fd359140) at ../libs/ardour/audiosource.cc:779
#24 0x00007f957394ee6b in ARDOUR::AudioSource::read_peaks_with_fpp(ARDOUR::PeakData*, long, long, long, double, long) const (this=0x55f6fd359140, peaks=0x55f700da6b80, npeaks=1356, start=113190, cnt=447480, samples_per_visual_peak=330, samples_per_file_peak=256) at ../libs/ardour/audiosource.cc:391
#25 0x00007f957394eb15 in ARDOUR::AudioSource::read_peaks(ARDOUR::PeakData*, long, long, long, double) const (this=0x55f6fd359140, peaks=0x55f700da6b80, npeaks=1356, start=113190, cnt=447480, samples_per_visual_peak=330) at ../libs/ardour/audiosource.cc:337
#26 0x00007f957393a905 in ARDOUR::AudioRegion::read_peaks(ARDOUR::PeakData*, long, long, long, unsigned int, double) const (this=
0x55f6fd84c3b0, buf=0x55f700da6b80, npeaks=1356, offset=113190, cnt=447480, chan_n=0, frames_per_pixel=330) at ../libs/ardour/audioregion.cc:431
#27 0x00007f9574f09caa in ArdourCanvas::WaveView::generate_image(boost::shared_ptr<ArdourCanvas::WaveViewThreadRequest>, bool) const (this=0x55f6fdf341a0, req=..., in_render_thread=false)
at ../libs/canvas/wave_view.cc:1005
#28 0x00007f9574f08e99 in ArdourCanvas::WaveView::get_image(long, long, bool&) const (this=0x55f6fdf341a0, start=225060, end=448800, full_image=@0x7ffc4d9070c7: false)
---Type <return> to continue, or q <return> to quit---
at ../libs/canvas/wave_view.cc:870
#29 0x00007f9574f0a6e8 in ArdourCanvas::WaveView::render(ArdourCanvas::Rect const&, Cairo::RefPtr<Cairo::Context>) const (this=0x55f6fdf341a0, area=..., context=...)
at ../libs/canvas/wave_view.cc:1180
*/
/* check that all waves are build and ready */
if (!tmp_waves.empty()) {
return;
}
ENSURE_GUI_THREAD (*this, &TapeAudioRegionView::update, n);
// CAIROCANVAS
2015-04-28 10:07:57 -04:00
/* this is a quick hack to draw something (abuse gain_changed to force
* an image-cache invalidation.
*
* TODO: ArdourCanvas::WaveView needs an API to look up the specific channel "n"
* and a special case to not only invalidate the cache but re-expose the
* waveform. e.g.
*
* waves[m]->rebuild(); // where 'm' corresponds to channel 'n'.
*/
for (uint32_t i = 0; i < waves.size(); ++i) {
waves[i]->gain_changed ();
}
#endif
}