Compare commits
3 Commits
master
...
devs/asdfu
Author | SHA1 | Date |
---|---|---|
Daniel Willmann | 8adcd71331 | |
Daniel Willmann | 27484f3c1b | |
Daniel Willmann | 4719b693e9 |
|
@ -87,18 +87,42 @@ handle_cmd(char *cmd, size_t bread)
|
|||
}
|
||||
else if (!strncmp(cmd, "+", bread))
|
||||
{
|
||||
if (volume <= 1.5)
|
||||
if (volume < 1.5)
|
||||
volume += 0.01;
|
||||
ecore_audio_output_volume_set(out, volume);
|
||||
printf("Volume: %3.0f%%\n", volume * 100);
|
||||
}
|
||||
else if (!strncmp(cmd, "-", bread))
|
||||
{
|
||||
if (volume >= 0)
|
||||
if (volume > 0)
|
||||
volume -= 0.01;
|
||||
ecore_audio_output_volume_set(out, volume);
|
||||
printf("Volume: %3.0f%%\n", volume * 100);
|
||||
}
|
||||
else if (!strncmp(cmd, "*", bread))
|
||||
{
|
||||
double speed;
|
||||
EINA_LIST_FOREACH(out_inputs, input, in)
|
||||
{
|
||||
speed = ecore_audio_input_speed_get(in);
|
||||
if (speed < 2.0)
|
||||
speed += 0.01;
|
||||
ecore_audio_input_speed_set(in, speed);
|
||||
printf("Speed: %3.0f%% (%s)\n", speed * 100, ecore_audio_input_name_get(in));
|
||||
}
|
||||
}
|
||||
else if (!strncmp(cmd, "/", bread))
|
||||
{
|
||||
double speed;
|
||||
EINA_LIST_FOREACH(out_inputs, input, in)
|
||||
{
|
||||
speed = ecore_audio_input_speed_get(in);
|
||||
if (speed > 0.5)
|
||||
speed -= 0.01;
|
||||
ecore_audio_input_speed_set(in, speed);
|
||||
printf("Speed: %3.0f%% (%s)\n", speed * 100, ecore_audio_input_name_get(in));
|
||||
}
|
||||
}
|
||||
else if (!strncmp(cmd, " ", bread))
|
||||
{
|
||||
EINA_LIST_FOREACH(out_inputs, input, in)
|
||||
|
|
|
@ -355,6 +355,27 @@ EAPI int ecore_audio_input_samplerate_get(Ecore_Audio_Object *input);
|
|||
*/
|
||||
EAPI void ecore_audio_input_samplerate_set(Ecore_Audio_Object *input, int samplerate);
|
||||
|
||||
/**
|
||||
* @brief Get the speed the input is played back at
|
||||
*
|
||||
* @param input The input
|
||||
*
|
||||
* @return The speed
|
||||
*
|
||||
* @since 1.8
|
||||
*/
|
||||
EAPI double ecore_audio_input_speed_get(Ecore_Audio_Object *input);
|
||||
|
||||
/**
|
||||
* @brief Set the speed the input is played back at
|
||||
*
|
||||
* @param input The input
|
||||
* @param samplerate The speed (1.0 is normal speed)
|
||||
*
|
||||
* @since 1.8
|
||||
*/
|
||||
EAPI void ecore_audio_input_speed_set(Ecore_Audio_Object *input, double speed);
|
||||
|
||||
/**
|
||||
* @brief Get the channels of the input
|
||||
*
|
||||
|
|
|
@ -341,6 +341,7 @@ ecore_audio_input_add(Ecore_Audio_Type type)
|
|||
in->module = module;
|
||||
in->output = NULL;
|
||||
in->paused = EINA_FALSE;
|
||||
in->speed = 1.0;
|
||||
|
||||
return module->in_ops->input_new((Ecore_Audio_Object *)in);
|
||||
}
|
||||
|
@ -420,6 +421,32 @@ EAPI void ecore_audio_input_samplerate_set(Ecore_Audio_Object *input, int sample
|
|||
}
|
||||
}
|
||||
|
||||
EAPI double ecore_audio_input_speed_get(Ecore_Audio_Object *input)
|
||||
{
|
||||
Ecore_Audio_Input* in = (Ecore_Audio_Input *)input;
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(in, 0);
|
||||
|
||||
return in->speed;
|
||||
}
|
||||
|
||||
EAPI void ecore_audio_input_speed_set(Ecore_Audio_Object *input, double speed)
|
||||
{
|
||||
Ecore_Audio_Input *in = (Ecore_Audio_Input *)input;
|
||||
EINA_SAFETY_ON_NULL_RETURN(input);
|
||||
Ecore_Audio_Module *outmod;
|
||||
|
||||
if ((in->speed == speed) || (speed < 0.2) || (speed > 5.0))
|
||||
return;
|
||||
|
||||
in->speed = speed;
|
||||
|
||||
if (in->output)
|
||||
{
|
||||
outmod = in->output->module;
|
||||
outmod->out_ops->output_update_input_format((Ecore_Audio_Object *)in->output, input);
|
||||
}
|
||||
}
|
||||
|
||||
EAPI int ecore_audio_input_channels_get(Ecore_Audio_Object *input)
|
||||
{
|
||||
Ecore_Audio_Input *in = (Ecore_Audio_Input *)input;
|
||||
|
|
|
@ -283,6 +283,7 @@ struct _Ecore_Audio_Input
|
|||
int samplerate;
|
||||
int channels;
|
||||
Eina_Bool looped; /**< Loop the sound */
|
||||
double speed;
|
||||
double length; /**< Length of the sound */
|
||||
Eina_Bool preloaded;
|
||||
Eina_Bool ended;
|
||||
|
|
|
@ -402,7 +402,7 @@ _pulse_output_add_input(Ecore_Audio_Object *output, Ecore_Audio_Object *input)
|
|||
|
||||
pa_sample_spec ss = {
|
||||
.format = PA_SAMPLE_FLOAT32LE,
|
||||
.rate = in->samplerate,
|
||||
.rate = in->samplerate * in->speed,
|
||||
.channels = in->channels,
|
||||
};
|
||||
|
||||
|
@ -416,7 +416,7 @@ _pulse_output_add_input(Ecore_Audio_Object *output, Ecore_Audio_Object *input)
|
|||
in->obj_data = stream;
|
||||
|
||||
pa_stream_set_write_callback(stream, _pulse_output_write_cb, in);
|
||||
pa_stream_connect_playback(stream, NULL, NULL, PA_STREAM_NOFLAGS, NULL, NULL);
|
||||
pa_stream_connect_playback(stream, NULL, NULL, PA_STREAM_VARIABLE_RATE, NULL, NULL);
|
||||
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
@ -449,7 +449,7 @@ _pulse_output_update_input_format(Ecore_Audio_Object *output EINA_UNUSED, Ecore_
|
|||
Ecore_Audio_Input *in = (Ecore_Audio_Input *)input;
|
||||
pa_stream *stream = (pa_stream *)in->obj_data;
|
||||
|
||||
pa_operation_unref(pa_stream_update_sample_rate(stream, in->samplerate, NULL, NULL));
|
||||
pa_operation_unref(pa_stream_update_sample_rate(stream, in->samplerate * in->speed, NULL, NULL));
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
|
@ -71,7 +71,7 @@ eet_snd_file_tell(Ecore_Audio_Object *in)
|
|||
#endif
|
||||
|
||||
Eina_Bool
|
||||
_edje_multisense_internal_sound_sample_play(Edje *ed, const char *sample_name, const double speed EINA_UNUSED)
|
||||
_edje_multisense_internal_sound_sample_play(Edje *ed, const char *sample_name, const double speed)
|
||||
{
|
||||
#ifdef ENABLE_MULTISENSE
|
||||
Ecore_Audio_Object *in;
|
||||
|
@ -99,6 +99,7 @@ _edje_multisense_internal_sound_sample_play(Edje *ed, const char *sample_name, c
|
|||
snprintf(snd_id_str, sizeof(snd_id_str), "edje/sounds/%i", sample->id);
|
||||
in = ecore_audio_input_add(ECORE_AUDIO_TYPE_SNDFILE);
|
||||
ecore_audio_input_name_set(in, snd_id_str);
|
||||
ecore_audio_input_speed_set(in, speed);
|
||||
|
||||
eet_data = calloc(1, sizeof(struct _edje_multisense_eet_data));
|
||||
ef = eet_open(ed->file->path, EET_FILE_MODE_READ);
|
||||
|
|
Loading…
Reference in New Issue