Re: [FFmpeg-devel] [PATCH][TESTERS WANTED] avfilter: add apitch filter

2019-05-12 Thread Paul B Mahol
On 5/12/19, Nicolas George  wrote:
> Paul B Mahol (12019-05-12):
>> You can not merge filters by removing other filters as that will break
>> user scripts.
>
> I know how do avoid that, thank you very much.
>

How would you avoid that?
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH][TESTERS WANTED] avfilter: add apitch filter

2019-05-12 Thread Nicolas George
Paul B Mahol (12019-05-12):
> You can not merge filters by removing other filters as that will break
> user scripts.

I know how do avoid that, thank you very much.

-- 
  Nicolas George


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH][TESTERS WANTED] avfilter: add apitch filter

2019-05-12 Thread Paul B Mahol
On 5/12/19, Nicolas George  wrote:
> Paul B Mahol (12019-05-12):
>> We have both setsar and setdar,
>
> And that is a mistake. We should have a single "set" filter that can
> change all the transparent numeric properties of frames (sar, time base,
> timestamp, colorspace, etc.). One of the benefits: it can notify users
> who set inconsistent values instead of just overriding them.
>
> Merging all this is one of my easy TODO list items.

You can not merge filters by removing other filters as that will break
user scripts.
Also there is already setparams filter.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH][TESTERS WANTED] avfilter: add apitch filter

2019-05-12 Thread Nicolas George
Paul B Mahol (12019-05-12):
> We have both setsar and setdar,

And that is a mistake. We should have a single "set" filter that can
change all the transparent numeric properties of frames (sar, time base,
timestamp, colorspace, etc.). One of the benefits: it can notify users
who set inconsistent values instead of just overriding them.

Merging all this is one of my easy TODO list items.

> why should we not have both atempo and apitch?

Because a single filter that can do both is less confusing: users do not
need to hesitate about which one to use.

-- 
  Nicolas George


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH][TESTERS WANTED] avfilter: add apitch filter

2019-05-12 Thread Paul B Mahol
On 5/12/19, Nicolas George  wrote:
> Paul B Mahol (12019-05-12):
>> Calling atempo filter atempo when it also modifies pitch is bad for users
>> and
>> at same time not having apitch filter, user would think that they can
>> not alter pitch.
>> Sorry if you can not understand my fears.
>
> As I have pointed to you (but you made a show of misunderstanding on
> purpose), changing the pitch and changing the speed of an audio signal
> are fundamentally the same thing, they are connected by the sample rate.
>
> In my experience, most people are aware of that, including completely
> non-technical people: they know that if you speed up or down a sound,
> its pitch changes.
>
> The documentation, of course, can be enhanced to make sure it contains
> all keyword a user is likely to search. And if the options can be
> tweaked to allow setting exactly the wanted output in the most
> convenient way (like we have a setdar, even though only the SAR exists
> in the library), it is even better.

We have both setsar and setdar, why should we not have both atempo and apitch?
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH][TESTERS WANTED] avfilter: add apitch filter

2019-05-12 Thread Nicolas George
Tim Jones (12019-05-12):
> Coming from the audio world, tempo, and pitch are different things.

Tempo and pitch are not the same thing. But changing them is the same
thing.

Regards,

-- 
  Nicolas George


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH][TESTERS WANTED] avfilter: add apitch filter

2019-05-12 Thread Tim Jones
On May 12, 2019, at 11:51 AM, Nicolas George  wrote:
> 
> Paul B Mahol (12019-05-12):
>> Calling atempo filter atempo when it also modifies pitch is bad for users and
>> at same time not having apitch filter, user would think that they can
>> not alter pitch.
>> Sorry if you can not understand my fears.
> 
> As I have pointed to you (but you made a show of misunderstanding on
> purpose), changing the pitch and changing the speed of an audio signal
> are fundamentally the same thing, they are connected by the sample rate.
> 
> In my experience, most people are aware of that, including completely
> non-technical people: they know that if you speed up or down a sound,
> its pitch changes.

Coming from the audio world, tempo, and pitch are different things.  Using a 
smart algorithm. I can speed up the tempo of clip without changing the pitch.  
Or, inversely, I can modify the pitch without changing the tempo.  We look at 
"tempo" as beats per period (usually minutes).  We look at pitch as the "tone 
and timbre" of a given sound (transposing a note from D to F#, for example).

> The documentation, of course, can be enhanced to make sure it contains
> all keyword a user is likely to search. And if the options can be
> tweaked to allow setting exactly the wanted output in the most
> convenient way (like we have a setdar, even though only the SAR exists
> in the library), it is even better.

This would be helpful since I had previously looked into adjusting the playback 
rate without the associate "Alvin and the Chipmunks" effect and didn't uncover 
anything within a deep DDG and Google search.

--
Tim

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH][TESTERS WANTED] avfilter: add apitch filter

2019-05-12 Thread Nicolas George
Paul B Mahol (12019-05-12):
> Calling atempo filter atempo when it also modifies pitch is bad for users and
> at same time not having apitch filter, user would think that they can
> not alter pitch.
> Sorry if you can not understand my fears.

As I have pointed to you (but you made a show of misunderstanding on
purpose), changing the pitch and changing the speed of an audio signal
are fundamentally the same thing, they are connected by the sample rate.

In my experience, most people are aware of that, including completely
non-technical people: they know that if you speed up or down a sound,
its pitch changes.

The documentation, of course, can be enhanced to make sure it contains
all keyword a user is likely to search. And if the options can be
tweaked to allow setting exactly the wanted output in the most
convenient way (like we have a setdar, even though only the SAR exists
in the library), it is even better.

-- 
  Nicolas George


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH][TESTERS WANTED] avfilter: add apitch filter

2019-05-12 Thread Paul B Mahol
On 5/12/19, Nicolas George  wrote:
> Paul B Mahol (12019-05-12):
>> That is hard problem, how would one know what implementation is best for
>> user scenario.
>
> Better developers who know the limits of their filters than users who do
> not know.
>
>> I disagree, current filter have artifacts with small scale factors.
>
> And that is what you are about to fix, is it not?
>
>> Looks like I missed to explain it in more fashion to you full
>> understanding,
>> it is filter that uses external library, do you still insist it to be
>> part of atempo?
>
> I know that. And yes, of course.
>
>> Looks like you missed to understand my detailed explanation.
>> Lets try it to explain in again, in more detailed fashion:
>> I mean there would be two filters doing same thing:
>> apitch with 1st option pitch and 2nd option tempo.
>> atempo with 1st option tempo and 2nd option pitch.
>> These filters would share same C file.
>
> Indeed, I missed the fact that you did not understand:
>
> No, there will no be an apitch filter, whether it lives in af_apitch.c
> or af_atempo.c. There will be a single filter, named atempo, that will
> bring the best quality to all users, existing and new ones.

Calling atempo filter atempo when it also modifies pitch is bad for users and
at same time not having apitch filter, user would think that they can
not alter pitch.
Sorry if you can not understand my fears.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH][TESTERS WANTED] avfilter: add apitch filter

2019-05-12 Thread Nicolas George
Paul B Mahol (12019-05-12):
> That is hard problem, how would one know what implementation is best for
> user scenario.

Better developers who know the limits of their filters than users who do
not know.

> I disagree, current filter have artifacts with small scale factors.

And that is what you are about to fix, is it not?

> Looks like I missed to explain it in more fashion to you full understanding,
> it is filter that uses external library, do you still insist it to be
> part of atempo?

I know that. And yes, of course.

> Looks like you missed to understand my detailed explanation.
> Lets try it to explain in again, in more detailed fashion:
> I mean there would be two filters doing same thing:
> apitch with 1st option pitch and 2nd option tempo.
> atempo with 1st option tempo and 2nd option pitch.
> These filters would share same C file.

Indeed, I missed the fact that you did not understand:

No, there will no be an apitch filter, whether it lives in af_apitch.c
or af_atempo.c. There will be a single filter, named atempo, that will
bring the best quality to all users, existing and new ones.

-- 
  Nicolas George


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH][TESTERS WANTED] avfilter: add apitch filter

2019-05-12 Thread Paul B Mahol
Hi,

On 5/12/19, Nicolas George  wrote:
> Paul B Mahol (12019-05-11):
>> It is currently separate filter for ease of testing.
>
> Then no problem. But I insist: once it is in shape, for the convenience
> of the users and ease of maintenance, it should be a single filter.
>
> Of course, if you disagree, we can discuss it here.
>
>> It can not be "part" of current atempo implementation for numerous
>> reasons,
>> most significant one being bad output quality with < 1 tempo scale
>> factor of current atempo implementation.
>
> This is one of the reasons it should be a single filter: the users
> should not need to know the arbitrary limits of different filters
> implementation. The filters are there to perform a task, and they should
> select the best implementation for it automatically.

That is hard problem, how would one know what implementation is best for
user scenario.

>
>> Also current atempo implementation have limits for minimal scale
>> reduction,
>
> IIRC, the limits were rather arbitrary. But even if they are not, my
> point stand: the filter should select the best implementation for the
> requested parameters, automatically without bothering the users.

I disagree, current filter have artifacts with small scale factors.

>
>> unlike rubberband filter in libavfilter. Also rubberband filter having
>> similar and bigger functionality.
>
> Oh, great, another filter with the same task. If I had noticed at the
> time, I would have insisted that it be part of atempo too at the time.

Looks like I missed to explain it in more fashion to you full understanding,
it is filter that uses external library, do you still insist it to be
part of atempo?

>
>> That's way I request for quality testers.
>> Best would be to compare this filter with rubberband and current atempo
>> filter.
>>
>> This filter is supposed to be current atempo full replacement.
>> (atempo would be just this filter but with same first two options but
>> with swapped positions).
>
> Swapping the position will break existing scripts. It should be avoided.

Looks like you missed to understand my detailed explanation.
Lets try it to explain in again, in more detailed fashion:
I mean there would be two filters doing same thing:
apitch with 1st option pitch and 2nd option tempo.
atempo with 1st option tempo and 2nd option pitch.
These filters would share same C file.

Regards, have a nice day
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH][TESTERS WANTED] avfilter: add apitch filter

2019-05-12 Thread Nicolas George
Paul B Mahol (12019-05-11):
> It is currently separate filter for ease of testing.

Then no problem. But I insist: once it is in shape, for the convenience
of the users and ease of maintenance, it should be a single filter.

Of course, if you disagree, we can discuss it here.

> It can not be "part" of current atempo implementation for numerous reasons,
> most significant one being bad output quality with < 1 tempo scale
> factor of current atempo implementation.

This is one of the reasons it should be a single filter: the users
should not need to know the arbitrary limits of different filters
implementation. The filters are there to perform a task, and they should
select the best implementation for it automatically.

> Also current atempo implementation have limits for minimal scale
> reduction,

IIRC, the limits were rather arbitrary. But even if they are not, my
point stand: the filter should select the best implementation for the
requested parameters, automatically without bothering the users.

> unlike rubberband filter in libavfilter. Also rubberband filter having
> similar and bigger functionality.

Oh, great, another filter with the same task. If I had noticed at the
time, I would have insisted that it be part of atempo too at the time.

> That's way I request for quality testers.
> Best would be to compare this filter with rubberband and current atempo 
> filter.
> 
> This filter is supposed to be current atempo full replacement.
> (atempo would be just this filter but with same first two options but
> with swapped positions).

Swapping the position will break existing scripts. It should be avoided.

> Options are self-explanatory, at least first two.
> Documentation will appear later.

Ok.

-- 
  Nicolas George


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH][TESTERS WANTED] avfilter: add apitch filter

2019-05-11 Thread Paul B Mahol
Hi,

On 5/11/19, Nicolas George  wrote:
> Paul B Mahol (12019-05-11):
>> Signed-off-by: Paul B Mahol 
>> ---
>>
>> This filter can dynamically change both tempo and pitch of audio.
>> Also scale range is bigger, from 0.01 to 100.
>>
>> ---
>>  libavfilter/Makefile |   1 +
>>  libavfilter/af_apitch.c  | 764 +++
>>  libavfilter/allfilters.c |   1 +
>>  3 files changed, 766 insertions(+)
>>  create mode 100644 libavfilter/af_apitch.c
>
> For usability and maintenance reasons already explained, must be part of
> atempo.

Thanks for kind and very helpful comments.

It is currently separate filter for ease of testing.
It can not be "part" of current atempo implementation for numerous reasons,
most significant one being bad output quality with < 1 tempo scale
factor of current
atempo implementation. Also current atempo implementation have limits
for minimal
scale reduction, unlike rubberband filter in libavfilter.
Also rubberband filter having similar and bigger functionality.

That's way I request for quality testers.
Best would be to compare this filter with rubberband and current atempo filter.

This filter is supposed to be current atempo full replacement.
(atempo would be just this filter but with same first two options but
with swapped positions).

>
> Also, missing doc.

Options are self-explanatory, at least first two.
Documentation will appear later.

Regards, and have a nice day.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH][TESTERS WANTED] avfilter: add apitch filter

2019-05-11 Thread Paul B Mahol
Signed-off-by: Paul B Mahol 
---

This filter can dynamically change both tempo and pitch of audio.
Also scale range is bigger, from 0.01 to 100.

---
 libavfilter/Makefile |   1 +
 libavfilter/af_apitch.c  | 764 +++
 libavfilter/allfilters.c |   1 +
 3 files changed, 766 insertions(+)
 create mode 100644 libavfilter/af_apitch.c

diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index b41304d480..3662d50ae0 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -68,6 +68,7 @@ OBJS-$(CONFIG_ANULL_FILTER)  += af_anull.o
 OBJS-$(CONFIG_APAD_FILTER)   += af_apad.o
 OBJS-$(CONFIG_APERMS_FILTER) += f_perms.o
 OBJS-$(CONFIG_APHASER_FILTER)+= af_aphaser.o 
generate_wave_table.o
+OBJS-$(CONFIG_APITCH_FILTER) += af_apitch.o
 OBJS-$(CONFIG_APULSATOR_FILTER)  += af_apulsator.o
 OBJS-$(CONFIG_AREALTIME_FILTER)  += f_realtime.o
 OBJS-$(CONFIG_ARESAMPLE_FILTER)  += af_aresample.o
diff --git a/libavfilter/af_apitch.c b/libavfilter/af_apitch.c
new file mode 100644
index 00..406951576b
--- /dev/null
+++ b/libavfilter/af_apitch.c
@@ -0,0 +1,764 @@
+/*
+ * Copyright (c) 2019 Paul B Mahol
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation; either version 2.1 of the License,
+ * or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "libswresample/swresample.h"
+#include "libavutil/avassert.h"
+#include "libavutil/avstring.h"
+#include "libavutil/audio_fifo.h"
+#include "libavfilter/internal.h"
+#include "libavutil/common.h"
+#include "libavutil/opt.h"
+#include "libavcodec/avfft.h"
+#include "filters.h"
+#include "audio.h"
+
+typedef struct APitchContext {
+const AVClass *class;
+
+float pitch;
+float tempo;
+int window_size;
+int ratio;
+
+int power_change;
+int fft_bits;
+int nb_channels;
+
+FFTContext *fft, *ifft;
+AVAudioFifo *ififo;
+int64_t pts;
+int eof;
+float *window_func_lut;
+
+AVFrame *buffer;
+AVFrame *magnitude;
+AVFrame *phase;
+AVFrame *acc;
+AVFrame *new_phase;
+AVFrame *last_phase;
+AVFrame *osamples;
+AVFrame *peaks;
+AVFrame *map;
+
+int   input_overlap;
+int   output_overlap;
+int   samples_to_drain;
+float last_power;
+
+intflushed;
+intpitch_changed;
+struct SwrContext *swr;
+} APitchContext;
+
+#define OFFSET(x) offsetof(APitchContext, x)
+#define AF AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
+
+static const AVOption apitch_options[] = {
+{ "pitch","set pitch scale factor", OFFSET(pitch),   
AV_OPT_TYPE_FLOAT, {.dbl=1},.01,   100, AF },
+{ "tempo","set tempo scale factor", OFFSET(tempo),   
AV_OPT_TYPE_FLOAT, {.dbl=1},.01,   100, AF },
+{ "oratio",   "set overlap ratio",  OFFSET(ratio),   
AV_OPT_TYPE_INT,   {.i64=4}, 1, 64, AF },
+{ NULL },
+};
+
+AVFILTER_DEFINE_CLASS(apitch);
+
+static int set_input_overlap(APitchContext *s, float rate)
+{
+s->input_overlap = s->output_overlap * rate;
+if (s->input_overlap <= 0)
+return AVERROR(EINVAL);
+return 0;
+}
+
+static int config_output(AVFilterLink *outlink)
+{
+AVFilterContext *ctx = outlink->src;
+AVFilterLink *inlink = ctx->inputs[0];
+APitchContext *s = ctx->priv;
+int ret;
+
+s->swr = swr_alloc();
+if (!s->swr)
+return AVERROR(ENOMEM);
+
+s->swr = swr_alloc_set_opts(s->swr,
+inlink->channel_layout, inlink->format, 
inlink->sample_rate,
+inlink->channel_layout, inlink->format, 
inlink->sample_rate * s->pitch,
+0, ctx);
+if (!s->swr)
+return AVERROR(ENOMEM);
+
+ret = swr_init(s->swr);
+if (ret < 0)
+return ret;
+
+s->window_size = inlink->sample_rate / 10;
+s->power_change = 1;
+s->pts  = AV_NOPTS_VALUE;
+s->fft_bits = av_log2(s->window_size);
+s->fft  = av_fft_init(s->fft_bits, 0);
+s->ifft = av_fft_init(s->fft_bits, 1);
+if (!s->fft || !s->ifft)
+return AVERROR(ENOMEM);
+
+s->window_size = 1 << s->fft_bits;
+
+s->ratio = FFMIN(1 << av_log2(s->ratio), s->window_size >> 1);
+s->nb_channels = outlink->channels;
+
+s->ififo = 

Re: [FFmpeg-devel] [PATCH][TESTERS WANTED] avfilter: add apitch filter

2019-05-11 Thread Nicolas George
Paul B Mahol (12019-05-11):
> Signed-off-by: Paul B Mahol 
> ---
> 
> This filter can dynamically change both tempo and pitch of audio.
> Also scale range is bigger, from 0.01 to 100.
> 
> ---
>  libavfilter/Makefile |   1 +
>  libavfilter/af_apitch.c  | 764 +++
>  libavfilter/allfilters.c |   1 +
>  3 files changed, 766 insertions(+)
>  create mode 100644 libavfilter/af_apitch.c

For usability and maintenance reasons already explained, must be part of
atempo.

Also, missing doc.

-- 
  Nicolas George


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".