Lines Matching refs:pitch
108 static gboolean gst_pitch_setcaps (GstPitch * pitch, GstCaps * caps);
123 GST_ELEMENT_REGISTER_DEFINE (pitch, "pitch", GST_RANK_NONE,
177 gst_pitch_init (GstPitch * pitch) in gst_pitch_init() argument
179 pitch->priv = (GstPitchPrivate *) gst_pitch_get_instance_private (pitch); in gst_pitch_init()
181 pitch->sinkpad = in gst_pitch_init()
183 gst_pad_set_chain_function (pitch->sinkpad, in gst_pitch_init()
185 gst_pad_set_event_function (pitch->sinkpad, in gst_pitch_init()
187 GST_PAD_SET_PROXY_CAPS (pitch->sinkpad); in gst_pitch_init()
188 gst_element_add_pad (GST_ELEMENT (pitch), pitch->sinkpad); in gst_pitch_init()
190 pitch->srcpad = in gst_pitch_init()
192 gst_pad_set_event_function (pitch->srcpad, in gst_pitch_init()
194 gst_pad_set_query_function (pitch->srcpad, in gst_pitch_init()
196 GST_PAD_SET_PROXY_CAPS (pitch->sinkpad); in gst_pitch_init()
197 gst_element_add_pad (GST_ELEMENT (pitch), pitch->srcpad); in gst_pitch_init()
199 pitch->priv->st = new soundtouch::SoundTouch (); in gst_pitch_init()
201 pitch->tempo = 1.0; in gst_pitch_init()
202 pitch->rate = 1.0; in gst_pitch_init()
203 pitch->out_seg_rate = 1.0; in gst_pitch_init()
204 pitch->seg_arate = 1.0; in gst_pitch_init()
205 pitch->pitch = 1.0; in gst_pitch_init()
206 pitch->next_buffer_time = GST_CLOCK_TIME_NONE; in gst_pitch_init()
207 pitch->next_buffer_offset = 0; in gst_pitch_init()
209 pitch->priv->st->setRate (pitch->rate); in gst_pitch_init()
210 pitch->priv->st->setTempo (pitch->tempo * pitch->seg_arate); in gst_pitch_init()
211 pitch->priv->st->setPitch (pitch->pitch); in gst_pitch_init()
213 pitch->priv->stream_time_ratio = 1.0; in gst_pitch_init()
214 pitch->min_latency = pitch->max_latency = 0; in gst_pitch_init()
221 GstPitch *pitch = GST_PITCH (object); in gst_pitch_dispose() local
223 if (pitch->priv->st) { in gst_pitch_dispose()
224 delete pitch->priv->st; in gst_pitch_dispose()
226 pitch->priv->st = NULL; in gst_pitch_dispose()
233 gst_pitch_update_duration (GstPitch * pitch) in gst_pitch_update_duration() argument
237 m = gst_message_new_duration_changed (GST_OBJECT (pitch)); in gst_pitch_update_duration()
238 gst_element_post_message (GST_ELEMENT (pitch), m); in gst_pitch_update_duration()
245 GstPitch *pitch = GST_PITCH (object); in gst_pitch_set_property() local
247 GST_OBJECT_LOCK (pitch); in gst_pitch_set_property()
250 pitch->tempo = g_value_get_float (value); in gst_pitch_set_property()
251 pitch->priv->stream_time_ratio = in gst_pitch_set_property()
252 pitch->tempo * pitch->rate * pitch->seg_arate; in gst_pitch_set_property()
253 pitch->priv->st->setTempo (pitch->tempo * pitch->seg_arate); in gst_pitch_set_property()
254 GST_OBJECT_UNLOCK (pitch); in gst_pitch_set_property()
255 gst_pitch_update_duration (pitch); in gst_pitch_set_property()
258 pitch->rate = g_value_get_float (value); in gst_pitch_set_property()
259 pitch->priv->stream_time_ratio = in gst_pitch_set_property()
260 pitch->tempo * pitch->rate * pitch->seg_arate; in gst_pitch_set_property()
261 pitch->priv->st->setRate (pitch->rate); in gst_pitch_set_property()
262 GST_OBJECT_UNLOCK (pitch); in gst_pitch_set_property()
263 gst_pitch_update_duration (pitch); in gst_pitch_set_property()
267 pitch->out_seg_rate = g_value_get_float (value); in gst_pitch_set_property()
268 GST_OBJECT_UNLOCK (pitch); in gst_pitch_set_property()
271 pitch->pitch = g_value_get_float (value); in gst_pitch_set_property()
272 pitch->priv->st->setPitch (pitch->pitch); in gst_pitch_set_property()
273 GST_OBJECT_UNLOCK (pitch); in gst_pitch_set_property()
277 GST_OBJECT_UNLOCK (pitch); in gst_pitch_set_property()
286 GstPitch *pitch = GST_PITCH (object); in gst_pitch_get_property() local
288 GST_OBJECT_LOCK (pitch); in gst_pitch_get_property()
291 g_value_set_float (value, pitch->tempo); in gst_pitch_get_property()
294 g_value_set_float (value, pitch->rate); in gst_pitch_get_property()
297 g_value_set_float (value, pitch->out_seg_rate); in gst_pitch_get_property()
300 g_value_set_float (value, pitch->pitch); in gst_pitch_get_property()
306 GST_OBJECT_UNLOCK (pitch); in gst_pitch_get_property()
310 gst_pitch_setcaps (GstPitch * pitch, GstCaps * caps) in gst_pitch_setcaps() argument
314 priv = GST_PITCH_GET_PRIVATE (pitch); in gst_pitch_setcaps()
316 if (!gst_audio_info_from_caps (&pitch->info, caps)) in gst_pitch_setcaps()
319 GST_OBJECT_LOCK (pitch); in gst_pitch_setcaps()
322 priv->st->setSampleRate (pitch->info.rate); in gst_pitch_setcaps()
323 priv->st->setChannels (pitch->info.channels); in gst_pitch_setcaps()
325 GST_OBJECT_UNLOCK (pitch); in gst_pitch_setcaps()
332 gst_pitch_forward_buffer (GstPitch * pitch, GstBuffer * buffer) in gst_pitch_forward_buffer() argument
336 GST_BUFFER_TIMESTAMP (buffer) = pitch->next_buffer_time; in gst_pitch_forward_buffer()
337 pitch->next_buffer_time += GST_BUFFER_DURATION (buffer); in gst_pitch_forward_buffer()
340 GST_BUFFER_OFFSET (buffer) = pitch->next_buffer_offset; in gst_pitch_forward_buffer()
341 pitch->next_buffer_offset += samples; in gst_pitch_forward_buffer()
342 GST_BUFFER_OFFSET_END (buffer) = pitch->next_buffer_offset; in gst_pitch_forward_buffer()
346 GST_TIME_ARGS (pitch->next_buffer_time), samples); in gst_pitch_forward_buffer()
348 return gst_pad_push (pitch->srcpad, buffer); in gst_pitch_forward_buffer()
353 gst_pitch_prepare_buffer (GstPitch * pitch) in gst_pitch_prepare_buffer() argument
360 priv = GST_PITCH_GET_PRIVATE (pitch); in gst_pitch_prepare_buffer()
362 GST_LOG_OBJECT (pitch, "preparing buffer"); in gst_pitch_prepare_buffer()
364 samples = pitch->priv->st->numSamples (); in gst_pitch_prepare_buffer()
368 buffer = gst_buffer_new_and_alloc (samples * pitch->info.bpf); in gst_pitch_prepare_buffer()
380 gst_util_uint64_scale (samples, GST_SECOND, pitch->info.rate); in gst_pitch_prepare_buffer()
391 gst_pitch_flush_buffer (GstPitch * pitch, gboolean send) in gst_pitch_flush_buffer() argument
395 if (pitch->priv->st->numUnprocessedSamples() != 0) { in gst_pitch_flush_buffer()
396 GST_DEBUG_OBJECT (pitch, "flushing buffer"); in gst_pitch_flush_buffer()
397 pitch->priv->st->flush (); in gst_pitch_flush_buffer()
403 buffer = gst_pitch_prepare_buffer (pitch); in gst_pitch_flush_buffer()
408 return gst_pitch_forward_buffer (pitch, buffer); in gst_pitch_flush_buffer()
414 GstPitch *pitch; in gst_pitch_src_event() local
417 pitch = GST_PITCH (parent); in gst_pitch_src_event()
432 GST_OBJECT_LOCK (pitch); in gst_pitch_src_event()
433 stream_time_ratio = pitch->priv->stream_time_ratio; in gst_pitch_src_event()
434 GST_OBJECT_UNLOCK (pitch); in gst_pitch_src_event()
453 GST_WARNING_OBJECT (pitch, in gst_pitch_src_event()
470 gst_pitch_convert (GstPitch * pitch, in gst_pitch_convert() argument
480 GST_OBJECT_LOCK (pitch); in gst_pitch_convert()
481 sample_size = pitch->info.bpf; in gst_pitch_convert()
482 samplerate = pitch->info.rate; in gst_pitch_convert()
483 GST_OBJECT_UNLOCK (pitch); in gst_pitch_convert()
551 GstPitch *pitch; in gst_pitch_src_query() local
557 pitch = GST_PITCH (parent); in gst_pitch_src_query()
561 GST_OBJECT_LOCK (pitch); in gst_pitch_src_query()
562 stream_time_ratio = pitch->priv->stream_time_ratio; in gst_pitch_src_query()
563 next_buffer_time = pitch->next_buffer_time; in gst_pitch_src_query()
564 next_buffer_offset = pitch->next_buffer_offset; in gst_pitch_src_query()
565 GST_OBJECT_UNLOCK (pitch); in gst_pitch_src_query()
573 GST_DEBUG_OBJECT (pitch, "upstream provided no duration"); in gst_pitch_src_query()
580 GST_DEBUG_OBJECT (pitch, "not TIME or DEFAULT format"); in gst_pitch_src_query()
583 GST_LOG_OBJECT (pitch, "upstream duration: %" G_GINT64_FORMAT, duration); in gst_pitch_src_query()
585 GST_LOG_OBJECT (pitch, "our duration: %" G_GINT64_FORMAT, duration); in gst_pitch_src_query()
597 GST_DEBUG_OBJECT (pitch, "not TIME or DEFAULT format"); in gst_pitch_src_query()
610 GST_LOG_OBJECT (pitch, "our position: %" G_GINT64_FORMAT, dst_value); in gst_pitch_src_query()
622 res = gst_pitch_convert (pitch, src_format, src_value, in gst_pitch_src_query()
637 if ((peer = gst_pad_get_peer (pitch->sinkpad))) { in gst_pitch_src_query()
649 GST_TIME_ARGS (pitch->min_latency), in gst_pitch_src_query()
650 GST_TIME_ARGS (pitch->max_latency)); in gst_pitch_src_query()
652 min += pitch->min_latency; in gst_pitch_src_query()
654 max += pitch->max_latency; in gst_pitch_src_query()
680 gst_pitch_process_segment (GstPitch * pitch, GstEvent ** event) in gst_pitch_process_segment() argument
689 GST_OBJECT_LOCK (pitch); in gst_pitch_process_segment()
690 stream_time_ratio = pitch->priv->stream_time_ratio; in gst_pitch_process_segment()
691 out_seg_rate = pitch->out_seg_rate; in gst_pitch_process_segment()
692 GST_OBJECT_UNLOCK (pitch); in gst_pitch_process_segment()
697 GST_WARNING_OBJECT (pitch, in gst_pitch_process_segment()
712 GST_LOG_OBJECT (pitch->sinkpad, "in segment %" GST_SEGMENT_FORMAT, &seg); in gst_pitch_process_segment()
714 stream_time_ratio = pitch->tempo * pitch->rate * pitch->seg_arate; in gst_pitch_process_segment()
717 GST_LOG_OBJECT (pitch->sinkpad, "stream_time_ratio is zero"); in gst_pitch_process_segment()
722 GST_OBJECT_LOCK (pitch); in gst_pitch_process_segment()
723 pitch->seg_arate = our_arate; in gst_pitch_process_segment()
724 pitch->priv->stream_time_ratio = stream_time_ratio; in gst_pitch_process_segment()
725 pitch->priv->st->setTempo (pitch->tempo * pitch->seg_arate); in gst_pitch_process_segment()
726 GST_OBJECT_UNLOCK (pitch); in gst_pitch_process_segment()
734 GST_LOG_OBJECT (pitch->sinkpad, "out segment %" GST_SEGMENT_FORMAT, &seg); in gst_pitch_process_segment()
748 GstPitch *pitch; in gst_pitch_sink_event() local
750 pitch = GST_PITCH (parent); in gst_pitch_sink_event()
756 gst_pitch_flush_buffer (pitch, FALSE); in gst_pitch_sink_event()
757 pitch->priv->st->clear (); in gst_pitch_sink_event()
758 pitch->next_buffer_offset = 0; in gst_pitch_sink_event()
759 pitch->next_buffer_time = GST_CLOCK_TIME_NONE; in gst_pitch_sink_event()
760 pitch->min_latency = pitch->max_latency = 0; in gst_pitch_sink_event()
763 gst_pitch_flush_buffer (pitch, TRUE); in gst_pitch_sink_event()
764 pitch->priv->st->clear (); in gst_pitch_sink_event()
765 pitch->min_latency = pitch->max_latency = 0; in gst_pitch_sink_event()
768 if (!gst_pitch_process_segment (pitch, &event)) { in gst_pitch_sink_event()
770 if (GST_PITCH_GET_PRIVATE (pitch)->pending_segment) in gst_pitch_sink_event()
771 gst_event_unref (GST_PITCH_GET_PRIVATE (pitch)->pending_segment); in gst_pitch_sink_event()
772 GST_PITCH_GET_PRIVATE (pitch)->pending_segment = event; in gst_pitch_sink_event()
775 pitch->priv->st->clear (); in gst_pitch_sink_event()
776 pitch->min_latency = pitch->max_latency = 0; in gst_pitch_sink_event()
783 res = gst_pitch_setcaps (pitch, caps); in gst_pitch_sink_event()
802 gst_pitch_update_latency (GstPitch * pitch, GstClockTime timestamp) in gst_pitch_update_latency() argument
807 (GstClockTimeDiff) (timestamp / pitch->priv->stream_time_ratio) - in gst_pitch_update_latency()
808 pitch->next_buffer_time; in gst_pitch_update_latency()
810 min_latency = MIN (pitch->min_latency, current_latency); in gst_pitch_update_latency()
811 max_latency = MAX (pitch->max_latency, current_latency); in gst_pitch_update_latency()
813 if (pitch->min_latency != min_latency || pitch->max_latency != max_latency) { in gst_pitch_update_latency()
814 pitch->min_latency = min_latency; in gst_pitch_update_latency()
815 pitch->max_latency = max_latency; in gst_pitch_update_latency()
822 gst_element_post_message (GST_ELEMENT (pitch), in gst_pitch_update_latency()
823 gst_message_new_latency (GST_OBJECT (pitch))); in gst_pitch_update_latency()
830 GstPitch *pitch; in gst_pitch_chain() local
835 pitch = GST_PITCH (parent); in gst_pitch_chain()
836 priv = GST_PITCH_GET_PRIVATE (pitch); in gst_pitch_chain()
841 if (!GST_CLOCK_TIME_IS_VALID (pitch->next_buffer_time)) { in gst_pitch_chain()
845 GST_OBJECT_LOCK (pitch); in gst_pitch_chain()
847 GST_OBJECT_UNLOCK (pitch); in gst_pitch_chain()
849 pitch->next_buffer_time = timestamp / stream_time_ratio; in gst_pitch_chain()
850 gst_pitch_convert (pitch, GST_FORMAT_TIME, timestamp, &out_format, in gst_pitch_chain()
851 &pitch->next_buffer_offset); in gst_pitch_chain()
854 gst_object_sync_values (GST_OBJECT (pitch), pitch->next_buffer_time); in gst_pitch_chain()
857 GST_LOG_OBJECT (pitch, "incoming buffer (%d samples) %" GST_TIME_FORMAT, in gst_pitch_chain()
858 (gint) (gst_buffer_get_size (buffer) / pitch->info.bpf), in gst_pitch_chain()
861 if (GST_PITCH_GET_PRIVATE (pitch)->pending_segment) { in gst_pitch_chain()
863 gst_event_copy (GST_PITCH_GET_PRIVATE (pitch)->pending_segment); in gst_pitch_chain()
865 GST_LOG_OBJECT (pitch, "processing stalled segment"); in gst_pitch_chain()
866 if (!gst_pitch_process_segment (pitch, &event)) { in gst_pitch_chain()
872 if (!gst_pad_event_default (pitch->sinkpad, parent, event)) { in gst_pitch_chain()
878 gst_event_unref (GST_PITCH_GET_PRIVATE (pitch)->pending_segment); in gst_pitch_chain()
879 GST_PITCH_GET_PRIVATE (pitch)->pending_segment = NULL; in gst_pitch_chain()
883 GST_OBJECT_LOCK (pitch); in gst_pitch_chain()
884 priv->st->putSamples ((soundtouch::SAMPLETYPE *) info.data, info.size / pitch->info.bpf); in gst_pitch_chain()
885 GST_OBJECT_UNLOCK (pitch); in gst_pitch_chain()
891 gst_pitch_update_latency (pitch, timestamp); in gst_pitch_chain()
896 out_buffer = gst_pitch_prepare_buffer (pitch); in gst_pitch_chain()
898 return gst_pitch_forward_buffer (pitch, out_buffer); in gst_pitch_chain()
908 GstPitch *pitch = GST_PITCH (element); in gst_pitch_change_state() local
914 pitch->next_buffer_time = GST_CLOCK_TIME_NONE; in gst_pitch_change_state()
915 pitch->next_buffer_offset = 0; in gst_pitch_change_state()
916 pitch->priv->st->clear (); in gst_pitch_change_state()
917 pitch->min_latency = pitch->max_latency = 0; in gst_pitch_change_state()
933 if (GST_PITCH_GET_PRIVATE (pitch)->pending_segment) { in gst_pitch_change_state()
934 gst_event_unref (GST_PITCH_GET_PRIVATE (pitch)->pending_segment); in gst_pitch_change_state()
935 GST_PITCH_GET_PRIVATE (pitch)->pending_segment = NULL; in gst_pitch_change_state()