mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-10 17:35:59 +00:00
cleaned up some code and integrated with new adder (mixer now works with different types of files)
Original commit message from CVS: * cleaned up some code and integrated with new adder (mixer now works with different types of files)
This commit is contained in:
parent
7c5e80c383
commit
bbb7ab7055
2 changed files with 56 additions and 16 deletions
|
@ -1,6 +1,18 @@
|
||||||
|
/*
|
||||||
|
* mixer.c - stereo audio mixer - thomas@apestaart.org
|
||||||
|
* example based on helloworld by
|
||||||
|
* demonstrates the adder plugin and the volume envelope plugin
|
||||||
|
* work in progress but do try it out
|
||||||
|
*
|
||||||
|
* Latest change : 16/04/2001
|
||||||
|
* mixer & adder plugin now work with variable-size input buffers
|
||||||
|
* Version : 0.2
|
||||||
|
*/
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <gst/gst.h>
|
#include <gst/gst.h>
|
||||||
#include "mixer.h"
|
#include "mixer.h"
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
//#define DEBUG
|
//#define DEBUG
|
||||||
|
|
||||||
|
@ -12,16 +24,13 @@ void destroy_input_channel (input_channel_t *pipe);
|
||||||
|
|
||||||
gboolean playing;
|
gboolean playing;
|
||||||
|
|
||||||
/* example based on helloworld by thomas@apestaart.org
|
|
||||||
demonstrates the adder plugin and the volume envelope plugin
|
|
||||||
work in progress but do try it out */
|
|
||||||
|
|
||||||
/* eos will be called when the src element has an end of stream */
|
/* eos will be called when the src element has an end of stream */
|
||||||
void eos(GstElement *element)
|
void eos(GstElement *element)
|
||||||
{
|
{
|
||||||
g_print("have eos, quitting\n");
|
g_print("have eos, quitting ?\n");
|
||||||
|
|
||||||
playing = FALSE;
|
// playing = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -128,12 +137,22 @@ int main(int argc,char *argv[])
|
||||||
gtk_object_set(GTK_OBJECT(channel_in1->volenv), "controlpoint", "10:1", NULL);
|
gtk_object_set(GTK_OBJECT(channel_in1->volenv), "controlpoint", "10:1", NULL);
|
||||||
gtk_object_set(GTK_OBJECT(channel_in1->volenv), "controlpoint", "15:1", NULL);
|
gtk_object_set(GTK_OBJECT(channel_in1->volenv), "controlpoint", "15:1", NULL);
|
||||||
gtk_object_set(GTK_OBJECT(channel_in1->volenv), "controlpoint", "20:0.000001", NULL);
|
gtk_object_set(GTK_OBJECT(channel_in1->volenv), "controlpoint", "20:0.000001", NULL);
|
||||||
|
gtk_object_set(GTK_OBJECT(channel_in1->volenv), "controlpoint", "40:0.000001", NULL);
|
||||||
|
gtk_object_set(GTK_OBJECT(channel_in1->volenv), "controlpoint", "45:0.5", NULL);
|
||||||
|
|
||||||
gtk_object_set(GTK_OBJECT(channel_in2->volenv), "controlpoint", "0:1", NULL);
|
gtk_object_set(GTK_OBJECT(channel_in2->volenv), "controlpoint", "0:1", NULL);
|
||||||
gtk_object_set(GTK_OBJECT(channel_in2->volenv), "controlpoint", "5:1", NULL);
|
gtk_object_set(GTK_OBJECT(channel_in2->volenv), "controlpoint", "5:1", NULL);
|
||||||
gtk_object_set(GTK_OBJECT(channel_in2->volenv), "controlpoint", "10:0.000001", NULL);
|
gtk_object_set(GTK_OBJECT(channel_in2->volenv), "controlpoint", "10:0.000001", NULL);
|
||||||
gtk_object_set(GTK_OBJECT(channel_in2->volenv), "controlpoint", "15:0.000001", NULL);
|
gtk_object_set(GTK_OBJECT(channel_in2->volenv), "controlpoint", "15:0.000001", NULL);
|
||||||
gtk_object_set(GTK_OBJECT(channel_in2->volenv), "controlpoint", "20:1", NULL);
|
gtk_object_set(GTK_OBJECT(channel_in2->volenv), "controlpoint", "20:1", NULL);
|
||||||
|
gtk_object_set(GTK_OBJECT(channel_in2->volenv), "controlpoint", "40:1", NULL);
|
||||||
|
gtk_object_set(GTK_OBJECT(channel_in2->volenv), "controlpoint", "45:0.5", NULL);
|
||||||
|
|
||||||
|
/* sleep a few seconds */
|
||||||
|
|
||||||
|
printf ("Sleeping a few seconds ...\n");
|
||||||
|
sleep (2);
|
||||||
|
printf ("Waking up ...\n");
|
||||||
|
|
||||||
/* start playing */
|
/* start playing */
|
||||||
gst_element_set_state(main_bin, GST_STATE_PLAYING);
|
gst_element_set_state(main_bin, GST_STATE_PLAYING);
|
||||||
|
@ -211,9 +230,10 @@ create_input_channel (int id, char* location)
|
||||||
/* add disksrc to the bin before autoplug */
|
/* add disksrc to the bin before autoplug */
|
||||||
gst_bin_add(GST_BIN(channel->pipe), channel->disksrc);
|
gst_bin_add(GST_BIN(channel->pipe), channel->disksrc);
|
||||||
|
|
||||||
/* gtk_signal_connect(GTK_OBJECT(disksrc1),"eos",
|
/* connect signal to eos of disksrc */
|
||||||
|
gtk_signal_connect(GTK_OBJECT(channel->disksrc),"eos",
|
||||||
GTK_SIGNAL_FUNC(eos),NULL);
|
GTK_SIGNAL_FUNC(eos),NULL);
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
printf ("DEBUG : c_i_p : creating volume envelope\n");
|
printf ("DEBUG : c_i_p : creating volume envelope\n");
|
||||||
|
@ -255,7 +275,7 @@ create_input_channel (int id, char* location)
|
||||||
exit (-1);
|
exit (-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
gst_bin_add(GST_BIN(channel->pipe), channel->volenv);
|
gst_bin_add (GST_BIN(channel->pipe), channel->volenv);
|
||||||
gst_bin_add (GST_BIN (channel->pipe), new_element);
|
gst_bin_add (GST_BIN (channel->pipe), new_element);
|
||||||
|
|
||||||
gst_element_connect (channel->disksrc, "src", new_element, "sink");
|
gst_element_connect (channel->disksrc, "src", new_element, "sink");
|
||||||
|
|
|
@ -1,6 +1,18 @@
|
||||||
|
/*
|
||||||
|
* mixer.c - stereo audio mixer - thomas@apestaart.org
|
||||||
|
* example based on helloworld by
|
||||||
|
* demonstrates the adder plugin and the volume envelope plugin
|
||||||
|
* work in progress but do try it out
|
||||||
|
*
|
||||||
|
* Latest change : 16/04/2001
|
||||||
|
* mixer & adder plugin now work with variable-size input buffers
|
||||||
|
* Version : 0.2
|
||||||
|
*/
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <gst/gst.h>
|
#include <gst/gst.h>
|
||||||
#include "mixer.h"
|
#include "mixer.h"
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
//#define DEBUG
|
//#define DEBUG
|
||||||
|
|
||||||
|
@ -12,16 +24,13 @@ void destroy_input_channel (input_channel_t *pipe);
|
||||||
|
|
||||||
gboolean playing;
|
gboolean playing;
|
||||||
|
|
||||||
/* example based on helloworld by thomas@apestaart.org
|
|
||||||
demonstrates the adder plugin and the volume envelope plugin
|
|
||||||
work in progress but do try it out */
|
|
||||||
|
|
||||||
/* eos will be called when the src element has an end of stream */
|
/* eos will be called when the src element has an end of stream */
|
||||||
void eos(GstElement *element)
|
void eos(GstElement *element)
|
||||||
{
|
{
|
||||||
g_print("have eos, quitting\n");
|
g_print("have eos, quitting ?\n");
|
||||||
|
|
||||||
playing = FALSE;
|
// playing = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -128,12 +137,22 @@ int main(int argc,char *argv[])
|
||||||
gtk_object_set(GTK_OBJECT(channel_in1->volenv), "controlpoint", "10:1", NULL);
|
gtk_object_set(GTK_OBJECT(channel_in1->volenv), "controlpoint", "10:1", NULL);
|
||||||
gtk_object_set(GTK_OBJECT(channel_in1->volenv), "controlpoint", "15:1", NULL);
|
gtk_object_set(GTK_OBJECT(channel_in1->volenv), "controlpoint", "15:1", NULL);
|
||||||
gtk_object_set(GTK_OBJECT(channel_in1->volenv), "controlpoint", "20:0.000001", NULL);
|
gtk_object_set(GTK_OBJECT(channel_in1->volenv), "controlpoint", "20:0.000001", NULL);
|
||||||
|
gtk_object_set(GTK_OBJECT(channel_in1->volenv), "controlpoint", "40:0.000001", NULL);
|
||||||
|
gtk_object_set(GTK_OBJECT(channel_in1->volenv), "controlpoint", "45:0.5", NULL);
|
||||||
|
|
||||||
gtk_object_set(GTK_OBJECT(channel_in2->volenv), "controlpoint", "0:1", NULL);
|
gtk_object_set(GTK_OBJECT(channel_in2->volenv), "controlpoint", "0:1", NULL);
|
||||||
gtk_object_set(GTK_OBJECT(channel_in2->volenv), "controlpoint", "5:1", NULL);
|
gtk_object_set(GTK_OBJECT(channel_in2->volenv), "controlpoint", "5:1", NULL);
|
||||||
gtk_object_set(GTK_OBJECT(channel_in2->volenv), "controlpoint", "10:0.000001", NULL);
|
gtk_object_set(GTK_OBJECT(channel_in2->volenv), "controlpoint", "10:0.000001", NULL);
|
||||||
gtk_object_set(GTK_OBJECT(channel_in2->volenv), "controlpoint", "15:0.000001", NULL);
|
gtk_object_set(GTK_OBJECT(channel_in2->volenv), "controlpoint", "15:0.000001", NULL);
|
||||||
gtk_object_set(GTK_OBJECT(channel_in2->volenv), "controlpoint", "20:1", NULL);
|
gtk_object_set(GTK_OBJECT(channel_in2->volenv), "controlpoint", "20:1", NULL);
|
||||||
|
gtk_object_set(GTK_OBJECT(channel_in2->volenv), "controlpoint", "40:1", NULL);
|
||||||
|
gtk_object_set(GTK_OBJECT(channel_in2->volenv), "controlpoint", "45:0.5", NULL);
|
||||||
|
|
||||||
|
/* sleep a few seconds */
|
||||||
|
|
||||||
|
printf ("Sleeping a few seconds ...\n");
|
||||||
|
sleep (2);
|
||||||
|
printf ("Waking up ...\n");
|
||||||
|
|
||||||
/* start playing */
|
/* start playing */
|
||||||
gst_element_set_state(main_bin, GST_STATE_PLAYING);
|
gst_element_set_state(main_bin, GST_STATE_PLAYING);
|
||||||
|
@ -211,9 +230,10 @@ create_input_channel (int id, char* location)
|
||||||
/* add disksrc to the bin before autoplug */
|
/* add disksrc to the bin before autoplug */
|
||||||
gst_bin_add(GST_BIN(channel->pipe), channel->disksrc);
|
gst_bin_add(GST_BIN(channel->pipe), channel->disksrc);
|
||||||
|
|
||||||
/* gtk_signal_connect(GTK_OBJECT(disksrc1),"eos",
|
/* connect signal to eos of disksrc */
|
||||||
|
gtk_signal_connect(GTK_OBJECT(channel->disksrc),"eos",
|
||||||
GTK_SIGNAL_FUNC(eos),NULL);
|
GTK_SIGNAL_FUNC(eos),NULL);
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
printf ("DEBUG : c_i_p : creating volume envelope\n");
|
printf ("DEBUG : c_i_p : creating volume envelope\n");
|
||||||
|
@ -255,7 +275,7 @@ create_input_channel (int id, char* location)
|
||||||
exit (-1);
|
exit (-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
gst_bin_add(GST_BIN(channel->pipe), channel->volenv);
|
gst_bin_add (GST_BIN(channel->pipe), channel->volenv);
|
||||||
gst_bin_add (GST_BIN (channel->pipe), new_element);
|
gst_bin_add (GST_BIN (channel->pipe), new_element);
|
||||||
|
|
||||||
gst_element_connect (channel->disksrc, "src", new_element, "sink");
|
gst_element_connect (channel->disksrc, "src", new_element, "sink");
|
||||||
|
|
Loading…
Reference in a new issue