Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

AudioDub Class Reference

Dub the video with the contents of a wav. More...

Inheritance diagram for AudioDub:

Inheritance graph
[legend]
Collaboration diagram for AudioDub:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 AudioDub ()
virtual ~AudioDub ()
char * GetDescription () const
bool IsAFrameConsumer () const
void GetFrame (int16_t **aframe, int frequency, int channels, int &samples, double position, double frame_delta)
void AttachWidgets (GtkBin *bin)
void DetachWidgets (GtkBin *bin)
void InterpretWidgets (GtkBin *bin)
GtkEntry * getEntry () const

Static Public Member Functions

static void on_button_sub_file_clicked (GtkButton *button, gpointer user_data)

Private Attributes

GtkWidget * window
GtkCurve * curve
double offsetSecs
bool initiated
gfloat m_vector [MAX_VECTOR]

Detailed Description

Dub the video with the contents of a wav.

NB: To avoid crashes during a preview which starts without audio and then has it switched on midflow, the initiated flag is used to determine that audio is initialised correctly at the start of the effect... This has the unfortunate effect of making audio require a restart in the preview before it is actually played correctly...

Definition at line 359 of file audio_filters.cc.


Constructor & Destructor Documentation

AudioDub::AudioDub  )  [inline]
 

Definition at line 369 of file audio_filters.cc.

References curve, lookup_widget(), magick_glade, on_button_sub_file_clicked(), WavSelect::SetWavFileEntry(), WavSelect::SetWavInfoLabel(), WavSelect::WavFileSelected(), and window.

00369                 : initiated( false )
00370     {
00371         window = glade_xml_get_widget( magick_glade, "window_dub" );
00372         curve = GTK_CURVE( glade_xml_get_widget( magick_glade, "curve_dub" ) );
00373         g_signal_connect( G_OBJECT( lookup_widget( window, "button_dub_file" ) ),
00374             "clicked", G_CALLBACK( on_button_sub_file_clicked ), this );
00375         SetWavInfoLabel( GTK_LABEL( lookup_widget( window, "label_dub_info" ) ) );
00376         SetWavFileEntry( GTK_ENTRY( lookup_widget( window, "entry_dub_file" ) ) );
00377         WavFileSelected();
00378     }

virtual AudioDub::~AudioDub  )  [inline, virtual]
 

Definition at line 380 of file audio_filters.cc.

00381     {}


Member Function Documentation

void AudioDub::AttachWidgets GtkBin *  bin  )  [inline, virtual]
 

Reimplemented from GDKAudioFilter.

Definition at line 423 of file audio_filters.cc.

References curve, gtk_curve_reset_vector(), and window.

00424     {
00425         gtk_curve_reset_vector( curve );
00426         gtk_widget_reparent( ( GTK_BIN( window ) ) ->child, GTK_WIDGET( bin ) );
00427         while ( gtk_events_pending() )
00428             gtk_main_iteration();
00429         gtk_curve_set_curve_type( curve, GTK_CURVE_TYPE_LINEAR );
00430     }

void AudioDub::DetachWidgets GtkBin *  bin  )  [inline, virtual]
 

Reimplemented from GDKAudioFilter.

Definition at line 432 of file audio_filters.cc.

References window.

00433     {
00434         gtk_widget_reparent( ( GTK_BIN( bin ) ) ->child, GTK_WIDGET( window ) );
00435     }

char* AudioDub::GetDescription  )  const [inline, virtual]
 

Implements AudioFilter.

Definition at line 383 of file audio_filters.cc.

00384     {
00385         return _( "Dub" );
00386     }

GtkEntry* AudioDub::getEntry  )  const [inline]
 

Definition at line 444 of file audio_filters.cc.

References lookup_widget(), and window.

Referenced by on_button_sub_file_clicked().

00445     {
00446         return GTK_ENTRY( lookup_widget( window, "entry_dub_file" ) );
00447     }

void AudioDub::GetFrame int16_t **  aframe,
int  frequency,
int  channels,
int &  samples,
double  position,
double  frame_delta
[inline, virtual]
 

Implements AudioFilter.

Definition at line 393 of file audio_filters.cc.

References curve, WavSelect::GetAdjustedSamples(), GetSelectedFramesForFX(), initiated, WavSelect::IsSelected(), m_vector, MAX_VECTOR, offsetSecs, WavSelect::WavGetFrequency(), WavSelect::WavRead(), and WavSelect::WavStart().

00394     {
00395         if ( IsSelected() )
00396         {
00397             gtk_curve_get_vector( curve, MAX_VECTOR, m_vector );
00398             if ( !initiated )
00399             {
00400                 initiated = true;
00401                 // nasty approximation (sigh)
00402                 off_t byte_offset = ( int( offsetSecs * WavGetFrequency() )
00403                     + ( GetSelectedFramesForFX().GetIndex( position ) * GetAdjustedSamples( frequency, samples ) ) )
00404                     * channels * 2;
00405                 WavStart( frequency, samples, byte_offset );
00406             }
00407             int pos = int( position * MAX_VECTOR + 0.5 );
00408             samples = WavRead( aframe, frequency, channels, samples * channels * 2, m_vector[ pos ] );
00409         }
00410     }

void AudioDub::InterpretWidgets GtkBin *  bin  )  [inline, virtual]
 

Reimplemented from GDKAudioFilter.

Definition at line 437 of file audio_filters.cc.

References initiated, lookup_widget(), offsetSecs, and window.

00438     {
00439         GtkWidget *offsetSpin = lookup_widget( window, "spinbutton_dub_offset" );
00440         offsetSecs = gtk_spin_button_get_value( GTK_SPIN_BUTTON( offsetSpin ) );
00441         initiated = false;
00442     }

bool AudioDub::IsAFrameConsumer  )  const [inline, virtual]
 

Reimplemented from AudioFilter.

Definition at line 388 of file audio_filters.cc.

00389     {
00390         return false;
00391     }

static void AudioDub::on_button_sub_file_clicked GtkButton *  button,
gpointer  user_data
[inline, static]
 

Definition at line 413 of file audio_filters.cc.

References common, getEntry(), and KinoCommon::getFileToOpen().

Referenced by AudioDub().

00414     {
00415         char *filename = common->getFileToOpen( _("Choose an audio file"), false );
00416         if ( filename && strcmp( filename, "" ) )
00417         {
00418             AudioDub *me = static_cast< AudioDub* >( user_data );
00419             gtk_entry_set_text( me->getEntry(), filename );
00420         }
00421     }


Member Data Documentation

GtkCurve* AudioDub::curve [private]
 

Definition at line 363 of file audio_filters.cc.

Referenced by AttachWidgets(), AudioDub(), and GetFrame().

bool AudioDub::initiated [private]
 

Definition at line 365 of file audio_filters.cc.

Referenced by GetFrame(), and InterpretWidgets().

gfloat AudioDub::m_vector[MAX_VECTOR] [private]
 

Definition at line 366 of file audio_filters.cc.

Referenced by GetFrame().

double AudioDub::offsetSecs [private]
 

Definition at line 364 of file audio_filters.cc.

Referenced by GetFrame(), and InterpretWidgets().

GtkWidget* AudioDub::window [private]
 

Definition at line 362 of file audio_filters.cc.

Referenced by AttachWidgets(), AudioDub(), DetachWidgets(), getEntry(), and InterpretWidgets().


The documentation for this class was generated from the following file:
Generated on Sun Mar 11 22:12:44 2007 for Kino by  doxygen 1.4.2