+unsigned char *mlt_frame_get_waveform( mlt_frame this, int w, int h )
+{
+ int16_t *pcm = NULL;
+ mlt_properties properties = mlt_frame_properties( this );
+ mlt_audio_format format = mlt_audio_pcm;
+ int frequency = 32000; // lower frequency available?
+ int channels = 2;
+ double fps = mlt_properties_get_double( properties, "fps" );
+ int samples = mlt_sample_calculator( fps, frequency, mlt_frame_get_position( this ) );
+
+ // Get the pcm data
+ mlt_frame_get_audio( this, &pcm, &format, &frequency, &channels, &samples );
+
+ // Make an 8-bit buffer large enough to hold rendering
+ int size = w * h;
+ unsigned char *bitmap = ( unsigned char* )mlt_pool_alloc( size );
+ if ( bitmap != NULL )
+ memset( bitmap, 0, size );
+ mlt_properties_set_data( properties, "waveform", bitmap, size, ( mlt_destructor )mlt_pool_release, NULL );
+
+ // Render vertical lines
+ int16_t *ubound = pcm + samples * channels;
+ int skip = samples / w - 1;
+ int i, j, k;
+
+ // Iterate sample stream and along x coordinate
+ for ( i = 0; i < w && pcm < ubound; i++ )
+ {
+ // pcm data has channels interleaved
+ for ( j = 0; j < channels; j++ )
+ {
+ // Determine sample's magnitude from 2s complement;
+ int pcm_magnitude = *pcm < 0 ? ~(*pcm) + 1 : *pcm;
+ // The height of a line is the ratio of the magnitude multiplied by
+ // half the vertical resolution
+ int height = ( int )( ( double )( pcm_magnitude ) / 32768 * h / 2 );
+ // Determine the starting y coordinate - left channel above center,
+ // right channel below - currently assumes 2 channels
+ int displacement = ( h / 2 ) - ( 1 - j ) * height;
+ // Position buffer pointer using y coordinate, stride, and x coordinate
+ unsigned char *p = &bitmap[ i + displacement * w ];
+
+ // Draw vertical line
+ for ( k = 0; k < height; k++ )
+ p[ w * k ] = 0xFF;
+
+ pcm++;
+ }
+ pcm += skip * channels;
+ }
+
+ return bitmap;
+}
+
+mlt_producer mlt_frame_get_original_producer( mlt_frame this )