From patchwork Fri Oct 6 16:27:57 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Bradshaw X-Patchwork-Id: 5441 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.2.161.90 with SMTP id m26csp135397jah; Fri, 6 Oct 2017 09:28:11 -0700 (PDT) X-Received: by 10.28.8.212 with SMTP id 203mr1775862wmi.43.1507307291838; Fri, 06 Oct 2017 09:28:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507307291; cv=none; d=google.com; s=arc-20160816; b=r8Ov43efy7xxnyY+HqkqJEuv7X20If3qDykHso/pskS0Js2ky9qzuo+fVQPjnfjVjZ U+4AssJ98O0aObndJ5zVIR4JVzrr10AR+cNiFLrBfB7NxjsNuOYJRZKu7FU9gV+Lrims vN4+tcQOmOe1bb0NRL0RdoYxDYtN6QK3B17oVKjZDqB3vt3h3QoXCyMXpNSYfDaCNoir J8ekUa3CZgy7nP5wyykfheRrCw83L3QN2Jhi3hqhV7J0ifedOVwaWJDvZ+spJim1+HDu lnKHejId3cbFXV5++v/VKgdHqpMFvGJiTZaD2g7yVPzDaNUHYqqK+UnSV3VWFMSUobBz f5LQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:message-id:date:to:from:dkim-signature :delivered-to:arc-authentication-results; bh=eZOpHLS/G4aRsms2DWb7PMoaUQu2c0ZmKRm1ZAt9jAY=; b=Ryv2HzKQBcBA0p+GWOsCmUbiZoQtC4CbIHd1/ygp3RAlTcDmPLh2w91/zXrc7XLYH3 QsRy+u2Jt+19ZaqPohXXJfGSTn/2gAamfz37mv0v+Pvb/Tleo1z3EhIHV98APOh953cA XqbaX90ISLCpwFbDgcyQe6yuiuCZ8+7LyXNzKbc6vXCDlwIDvFgUgBXDJp3Upm0JZhQu JJt3l08pJ0aI2ZikR3g7UqxaNLynaZHzsiuCtqgKmr5kWWLVhgCZ6IYUttyr3ndBLSPe lNg0nNh5g8ubeGTMF2KK0/fY/41VoVI53Gp3yXyw+Vj5AZOHV8F2xivKh26nkL2MeEtT rz4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=qBHFYTar; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id c137si1661836wmh.9.2017.10.06.09.28.11; Fri, 06 Oct 2017 09:28:11 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=qBHFYTar; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 22E4568A2B0; Fri, 6 Oct 2017 19:28:07 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pf0-f195.google.com (mail-pf0-f195.google.com [209.85.192.195]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1BC3668A12C for ; Fri, 6 Oct 2017 19:28:01 +0300 (EEST) Received: by mail-pf0-f195.google.com with SMTP id m28so17000309pfi.0 for ; Fri, 06 Oct 2017 09:28:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=zH8OiAgkpit6F61oEVm2r7/g2FvNsk/efGIMYk4PNkU=; b=qBHFYTar4wITwnpgy/tSMpfQ7+zM1otoatoCYziPLGQGnRxkqA8VrXch0LCEd3zm5+ Il85cQVzFHfBQncqtu//bjR8UI6WnpuMwH0dA3jBCpPR+Grwd5Z76g+8FCNKFnDpMuWo V1SvMTpcHkB7eYg9I1sJt0L3aYS3d6NW5PuA4NPmXhOziIW9DhOIH+WNNpuKNEk/9Izu 8bDthZcPXMWy3uNphxSFXx6G6BfRfwMCEKDhkhHsANeSGXhvqB4IRPMllRoorFkQ33gX VK5oLx92C55U0MK689ye8bccAbBGdvDRM4bcPfUm40gbyU0W1w8RshQ8rFZT6GAYXMQg 1mCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=zH8OiAgkpit6F61oEVm2r7/g2FvNsk/efGIMYk4PNkU=; b=dYAuFYbfGZnGFLwE4VOXmi6D+GRKmCeiSAUWMhEBimIcsQxQ8Exd2PTLWzMe+j1mx0 DaYoJ0PkmbzQ115qtPXnXuUBdQQPN4hR0ZEh0XmXyKgl3D3WVuqh3FLgD8VRnFrutPoG 1rjjgzY1K+/y7VnV9rUKt63t5VE/UezoiGX+rVIu6IM7NIkmSUaTqi5dzF8dQTqMu1x3 7Lpzqnh1xcT45ENqkb1NIcXrEntEL9BOo+V/7zrfavlCWus8XIFUDMv5GHeNLX7Sf3FP DYukPbsbTFNngjHuGOT6ydBZ0djPefP7yMRkSVYEljapbrlSlN9IkiNBG16jMfSST7N7 yUaw== X-Gm-Message-State: AMCzsaVBTTEyXuJOcftBiJAmXZgf/hVKGufddUwd8/HNu62jyFsLoWoe fqaAKx6vGrOksQeOR1AXGbb+8ymn X-Google-Smtp-Source: AOwi7QCr7l575GSHeIIWwv9FJ/nVlgUMmiGe08as2h/wugvTvkRwLyQDqSRgKVT6cftma03trs+Amw== X-Received: by 10.84.238.136 with SMTP id v8mr2449471plk.37.1507307280005; Fri, 06 Oct 2017 09:28:00 -0700 (PDT) Received: from localhost.localdomain (c-73-189-103-209.hsd1.ca.comcast.net. [73.189.103.209]) by smtp.gmail.com with ESMTPSA id n2sm4637763pfa.118.2017.10.06.09.27.58 (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 06 Oct 2017 09:27:58 -0700 (PDT) From: Michael Bradshaw To: ffmpeg-devel@ffmpeg.org Date: Fri, 6 Oct 2017 09:27:57 -0700 Message-Id: <20171006162757.16574-1-mjbshaw@gmail.com> X-Mailer: git-send-email 2.13.5 (Apple Git-94) Subject: [FFmpeg-devel] [PATCH] lavf: add more beep options to sine asrc X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Michael Bradshaw MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" From: Michael Bradshaw Signed-off-by: Michael Bradshaw --- doc/filters.texi | 13 ++++++++++++- libavfilter/asrc_sine.c | 17 +++++++++++++---- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/doc/filters.texi b/doc/filters.texi index 57189c77b0..ec1c335950 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -4624,7 +4624,18 @@ Set the carrier frequency. Default is 440 Hz. @item beep_factor, b Enable a periodic beep every second with frequency @var{beep_factor} times -the carrier frequency. Default is 0, meaning the beep is disabled. +the carrier frequency. Default is 0, meaning the beep is disabled. If +@var{frequency} is 0, this value is interpreted as the beep frequency (in Hertz) +(rather than a multiplier of the @var{frequency}). + +@item beep_delay +The delay for the first beep, in seconds. Default is 0. + +@item beep_period +The time beriod between two beeps, in seconds. Default is 1. + +@item beep_duration +The duration of a beep, in seconds. Default is 0.04. @item sample_rate, r Specify the sample rate, default is 44100. diff --git a/libavfilter/asrc_sine.c b/libavfilter/asrc_sine.c index 3a87210b4b..643952792f 100644 --- a/libavfilter/asrc_sine.c +++ b/libavfilter/asrc_sine.c @@ -32,6 +32,9 @@ typedef struct SineContext { const AVClass *class; double frequency; double beep_factor; + double beep_delay; + double beep_period_opt; + double beep_duration; char *samples_per_frame; AVExpr *samples_per_frame_expr; int sample_rate; @@ -71,6 +74,9 @@ static const AVOption sine_options[] = { OPT_DBL("f", frequency, 440, 0, DBL_MAX, "set the sine frequency",), OPT_DBL("beep_factor", beep_factor, 0, 0, DBL_MAX, "set the beep frequency factor",), OPT_DBL("b", beep_factor, 0, 0, DBL_MAX, "set the beep frequency factor",), + OPT_DBL("beep_delay", beep_delay, 0, 0, DBL_MAX, "set the delay for the first beep",), + OPT_DBL("beep_period", beep_period_opt, 1, DBL_MIN, DBL_MAX, "set the gap between beeps",), + OPT_DBL("beep_duration", beep_duration, 0.04, DBL_MIN, DBL_MAX, "set the duration of a beep",), OPT_INT("sample_rate", sample_rate, 44100, 1, INT_MAX, "set the sample rate",), OPT_INT("r", sample_rate, 44100, 1, INT_MAX, "set the sample rate",), OPT_DUR("duration", duration, 0, 0, INT64_MAX, "set the audio duration",), @@ -152,10 +158,13 @@ static av_cold int init(AVFilterContext *ctx) make_sin_table(sine->sin); if (sine->beep_factor) { - sine->beep_period = sine->sample_rate; - sine->beep_length = sine->beep_period / 25; - sine->dphi_beep = ldexp(sine->beep_factor * sine->frequency, 32) / - sine->sample_rate + 0.5; + unsigned beep_start = sine->beep_delay * sine->sample_rate; + double beep_frequency = (sine->frequency ? sine->frequency : 1.0) * + sine->beep_factor; + sine->beep_period = sine->beep_period_opt * sine->sample_rate; + sine->beep_index = (sine->beep_period - beep_start) % sine->beep_period; + sine->beep_length = sine->beep_duration * sine->sample_rate; + sine->dphi_beep = ldexp(beep_frequency, 32) / sine->sample_rate + 0.5; } ret = av_expr_parse(&sine->samples_per_frame_expr,