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

WavSelect Class Reference

Inheritance diagram for WavSelect:

Inheritance graph
[legend]
Collaboration diagram for WavSelect:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 WavSelect ()
 ~WavSelect ()
void SetWavInfoLabel (GtkLabel *label)
void SetWavFileEntry (GtkEntry *entry)
void WavFileSelected ()
void WavStart (int frequency, int samples, off_t offset)
int WavRead (int16_t **a, int f, int c, int bytes, double gain=1.0)
bool IsSelected ()
int GetAdjustedSamples (int frequency, int samples) const
int WavGetFrequency ()

Private Attributes

char wav_file [PATH_MAX+NAME_MAX]
KinoAudioInputwav
GtkLabel * label_info
GtkEntry * file_entry
AudioResample< int16_le_t,
int16_ne_t > * 
resampler
int fps
int16_t temp [4 *DV_AUDIO_MAX_SAMPLES *2]
bool wav_selected

Constructor & Destructor Documentation

WavSelect::WavSelect  )  [inline]
 

Definition at line 200 of file audio_filters.cc.

References wav_file.

00200                 : wav( NULL ), label_info( NULL ), file_entry( NULL ), resampler(0), wav_selected( false )
00201     {
00202         strcpy( wav_file, "" );
00203     }

WavSelect::~WavSelect  )  [inline]
 

Definition at line 205 of file audio_filters.cc.

References resampler, and wav.

00206     {
00207         delete wav;
00208         delete resampler;
00209     }


Member Function Documentation

int WavSelect::GetAdjustedSamples int  frequency,
int  samples
const [inline]
 

Definition at line 332 of file audio_filters.cc.

References KinoAudioInput::GetFrequency(), and wav.

Referenced by AudioMix::GetFrame(), and AudioDub::GetFrame().

00333     {
00334         return samples * wav->GetFrequency() / frequency;
00335     }

bool WavSelect::IsSelected  )  [inline]
 

Definition at line 327 of file audio_filters.cc.

References wav_selected.

Referenced by AudioMix::GetFrame(), and AudioDub::GetFrame().

00328     {
00329         return wav_selected;
00330     }

void WavSelect::SetWavFileEntry GtkEntry *  entry  )  [inline]
 

Definition at line 216 of file audio_filters.cc.

References file_entry, and on_entry_file_changed().

Referenced by AudioDub::AudioDub(), and AudioMix::AudioMix().

00217     {
00218         file_entry = entry;
00219         g_signal_connect( G_OBJECT( entry ), "changed", G_CALLBACK( on_entry_file_changed ), this );
00220     }

void WavSelect::SetWavInfoLabel GtkLabel *  label  )  [inline]
 

Definition at line 211 of file audio_filters.cc.

References label_info.

Referenced by AudioDub::AudioDub(), and AudioMix::AudioMix().

00212     {
00213         label_info = label;
00214     }

void WavSelect::WavFileSelected  )  [inline]
 

Definition at line 222 of file audio_filters.cc.

References KinoAudioInputFactory::CreateAudioInput(), file_entry, KinoAudioInput::GetFrequency(), KinoAudioInput::GetNumberOfSamples(), label_info, wav, wav_file, and wav_selected.

Referenced by AudioDub::AudioDub(), and AudioMix::AudioMix().

00223     {
00224         char text[ 10240 ] = "";
00225 
00226         if ( strcmp( wav_file, gtk_entry_get_text( file_entry ) ) )
00227         {
00228             delete wav;
00229 
00230             strcpy( wav_file, gtk_entry_get_text( file_entry ) );
00231             this->wav = KinoAudioInputFactory::CreateAudioInput( wav_file );
00232 
00233             if ( wav != NULL )
00234             {
00235                 wav_selected = true;
00236                 if ( wav->GetNumberOfSamples() > 0 )
00237                 {
00238                     sprintf( text, _( "Duration: %.02f seconds" ),
00239                             ( double ) wav->GetNumberOfSamples() / ( double ) wav->GetFrequency() );
00240                 }
00241                 else
00242                 {
00243                     sprintf( text, _( "Duration: N/A" ) );
00244                 }
00245             }
00246             else
00247             {
00248                 wav_selected = false;
00249                 strcpy( text, _( "Invalid file selected" ) );
00250             }
00251         }
00252         else if ( !strcmp( wav_file, "" ) )
00253         {
00254             wav_selected = false;
00255             strcpy( text, _( "No file selected" ) );
00256         }
00257 
00258         if ( strcmp( text, "" ) )
00259             gtk_label_set_text( label_info, text );
00260     }

int WavSelect::WavGetFrequency  )  [inline]
 

Definition at line 337 of file audio_filters.cc.

References KinoAudioInput::GetFrequency(), and wav.

Referenced by AudioMix::GetFrame(), and AudioDub::GetFrame().

00338     {
00339         return wav->GetFrequency();
00340     }

int WavSelect::WavRead int16_t **  a,
int  f,
int  c,
int  bytes,
double  gain = 1.0
[inline]
 

Definition at line 292 of file audio_filters.cc.

References KinoAudioInput::Get(), KinoAudioInput::GetFrequency(), resampler, temp, wav, and wav_selected.

Referenced by AudioMix::GetFrame(), and AudioDub::GetFrame().

00293     {
00294         if ( wav_selected )
00295         {
00296             if ( resampler )
00297             {
00298                 memset( temp, 0, sizeof( temp ) );
00299                 int samples = bytes / c / 2 * wav->GetFrequency() / f;
00300                 bytes = samples * c * 2;
00301                 if ( !wav->Get( temp, bytes ) )
00302                     std::cerr << ">>> Underrun? unable to read " << bytes << " bytes" << std::endl;
00303     
00304                 resampler->Resample( reinterpret_cast<int16_le_t *>(temp), wav->GetFrequency(), c, samples );
00305     
00306                 int16_t *p = resampler->output;
00307                 for ( int s = 0; s < resampler->size / c / 2; s ++ )
00308                     for ( int i = 0; i < c; i ++ )
00309                         a[ i ][ s ] = int16_t( double( *p++ ) * gain + 0.5 );
00310                 return (resampler->size / c / 2);
00311             }
00312             else
00313             {
00314                 memset( temp, 0, sizeof( temp ) );
00315                 if ( !wav->Get( temp, bytes ) )
00316                     std::cerr << ">>> Underrun? unable to read " << bytes << " bytes" << std::endl;
00317                 int16_t *p = temp;
00318                 for ( int s = 0; s < bytes / c / 2; s ++ )
00319                     for ( int i = 0; i < c; i ++ )
00320                         a[ i ][ s ] = int16_t( double( *p++ ) * gain + 0.5 );
00321                 return (bytes / c / 2);
00322             }
00323         }
00324         return 0;
00325     }

void WavSelect::WavStart int  frequency,
int  samples,
off_t  offset
[inline]
 

Definition at line 262 of file audio_filters.cc.

References AUDIO_RESAMPLE_SRC_SINC_BEST_QUALITY, AudioResampleFactory< input_t, output_t >::createAudioResample(), fps, KinoAudioInput::Get(), KinoAudioInput::GetFrequency(), KinoAudioInput::Open(), resampler, KinoAudioInput::Seek(), AudioResample< input_t, output_t >::SetOutputFrequency(), wav, wav_file, and wav_selected.

Referenced by AudioMix::GetFrame(), and AudioDub::GetFrame().

00263     {
00264         if ( wav_selected )
00265         {
00266             if ( wav->GetFrequency() != frequency )
00267             {
00268                 delete resampler;
00269                 resampler = AudioResampleFactory<int16_le_t,int16_ne_t>::createAudioResample(
00270                     AUDIO_RESAMPLE_SRC_SINC_BEST_QUALITY );
00271                 resampler->SetOutputFrequency( frequency );
00272             }
00273             else
00274             {
00275                 delete resampler;
00276                 resampler = 0;
00277             }
00278             fps = frequency / samples;
00279             if ( ! wav->Seek( offset ) )
00280             {
00281                 int16_t data[2];
00282                 wav->Open( wav_file );
00283                 for ( off_t i = 0; i < offset; i += sizeof(data) )
00284                 {
00285                     if ( ! wav->Get( data, sizeof(data) ) )
00286                         break;
00287                 }
00288             }
00289         }
00290     }


Member Data Documentation

GtkEntry* WavSelect::file_entry [private]
 

Definition at line 193 of file audio_filters.cc.

Referenced by SetWavFileEntry(), and WavFileSelected().

int WavSelect::fps [private]
 

Definition at line 195 of file audio_filters.cc.

Referenced by WavStart().

GtkLabel* WavSelect::label_info [private]
 

Definition at line 192 of file audio_filters.cc.

Referenced by SetWavInfoLabel(), and WavFileSelected().

AudioResample<int16_le_t,int16_ne_t>* WavSelect::resampler [private]
 

Definition at line 194 of file audio_filters.cc.

Referenced by WavRead(), WavStart(), and ~WavSelect().

int16_t WavSelect::temp[4 *DV_AUDIO_MAX_SAMPLES *2] [private]
 

Definition at line 196 of file audio_filters.cc.

Referenced by WavRead().

KinoAudioInput* WavSelect::wav [private]
 

Definition at line 191 of file audio_filters.cc.

Referenced by GetAdjustedSamples(), WavFileSelected(), WavGetFrequency(), WavRead(), WavStart(), and ~WavSelect().

char WavSelect::wav_file[PATH_MAX+NAME_MAX] [private]
 

Definition at line 190 of file audio_filters.cc.

Referenced by WavFileSelected(), WavSelect(), and WavStart().

bool WavSelect::wav_selected [private]
 

Definition at line 197 of file audio_filters.cc.

Referenced by IsSelected(), WavFileSelected(), WavRead(), and WavStart().


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