From patchwork Fri Oct 23 17:46:10 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Caleb Crome X-Patchwork-Id: 7474201 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 8FB2F9F302 for ; Fri, 23 Oct 2015 17:47:08 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B3F23209F1 for ; Fri, 23 Oct 2015 17:47:07 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 7DC252078C for ; Fri, 23 Oct 2015 17:47:06 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 8FF48265206; Fri, 23 Oct 2015 19:47:05 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,NO_DNS_FOR_FROM, RCVD_IN_DNSWL_LOW, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id B58CB265051; Fri, 23 Oct 2015 19:46:27 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id 21B41264ED5; Fri, 23 Oct 2015 19:46:25 +0200 (CEST) Received: from mail-pa0-f53.google.com (mail-pa0-f53.google.com [209.85.220.53]) by alsa0.perex.cz (Postfix) with ESMTP id EF6182625ED for ; Fri, 23 Oct 2015 19:46:17 +0200 (CEST) Received: by pasz6 with SMTP id z6so123873816pas.2 for ; Fri, 23 Oct 2015 10:46:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=cEt2X0Nr+9TSkNIVlbmx0jGs/OljjH2m6NJNB7KDrfE=; b=bvq0bmhkfuJqw9FzcTBEY4+NbYewtXLQAl4GkR+SFasdHlVG5e/Hi66QsMYYeZc/Px OgrNYkntr4YSwyopPxkbH3EtaYUHkt9IjMc/ypOCOXXu58flKImULI2ieSA7Gposj8wM 2tJi6aEupCq82Uuvmj4YLKZjqEG4zlFtbr7jzSgPgzHxvX1+6yJgISVTwR7WrWJtcxUI /wmSH6px+2vfXosRU7d0b1/6gWvKucuFiRfJFCmzg4D+qOHYlTUnfp4FIGPfFX9HECf7 UpMRfb7VwmbgsFHlklYCronMjui+8wq6NQY0PlG+2S7L7ItdNOeLQp274TaElbpr/qXE V99Q== X-Gm-Message-State: ALoCoQkcgOzCQ9MXKB4YbUg6Y2wO/GBRT5cnHxtY6zOr2+QJO99pSM8kJUyHAqce3SCf9IA7g9Ko X-Received: by 10.66.136.39 with SMTP id px7mr25078770pab.23.1445622376937; Fri, 23 Oct 2015 10:46:16 -0700 (PDT) Received: from alarm.localdomain (99-113-34-250.lightspeed.sntcca.sbcglobal.net. [99.113.34.250]) by smtp.gmail.com with ESMTPSA id dd4sm20059961pbb.52.2015.10.23.10.46.15 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 23 Oct 2015 10:46:15 -0700 (PDT) From: Caleb Crome To: alsa-devel@alsa-project.org Date: Fri, 23 Oct 2015 17:46:10 +0000 Message-Id: <1445622370-18673-2-git-send-email-caleb@crome.org> X-Mailer: git-send-email 2.6.1 In-Reply-To: <1445622370-18673-1-git-send-email-caleb@crome.org> References: <1445622370-18673-1-git-send-email-caleb@crome.org> Cc: Caleb Crome Subject: [alsa-devel] [PATCH 2/2] BAT: Change maximum number of channels from 2 to 64 X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP Changed maximum number of channels to 64. Added a round-robbin frequency assignment from the command line so that every frequency need not be specified on the command line. For example, -c 6 -F 100:200:250 will result frequencies for the 6 channels to be set identically as if the command was -c 6 -F 100:200:250:100:200:250 Signed-off-by: Caleb Crome --- bat/bat.c | 37 ++++++++++++++++++++++++++----------- bat/common.h | 2 +- 2 files changed, 27 insertions(+), 12 deletions(-) diff --git a/bat/bat.c b/bat/bat.c index 086b9fa..9c046e6 100644 --- a/bat/bat.c +++ b/bat/bat.c @@ -73,16 +73,30 @@ err_exit: static void get_sine_frequencies(struct bat *bat, char *freq) { - char *tmp1; - - tmp1 = strchr(freq, ':'); - if (tmp1 == NULL) { - bat->target_freq[1] = bat->target_freq[0] = atof(optarg); - } else { - *tmp1 = '\0'; - bat->target_freq[0] = atof(optarg); - bat->target_freq[1] = atof(tmp1 + 1); + char *tmp0, *tmp1; + int ncolons; + int nfreqs; + int i; + ncolons = 0; + tmp1 = freq; + while ((tmp1 = strchr(tmp1, ':'))) { + tmp1++; + ncolons ++; + } + nfreqs = ncolons+1; + + tmp0 = freq; + tmp1 = strchr(tmp0, ':'); + for (i = 0; i < MAX_CHANNELS && i < nfreqs; i++) { + if (i+1 < nfreqs) + *tmp1 = '\0'; + bat->target_freq[i] = atof(tmp0); + tmp0 = tmp1+1; + if (i+1 < nfreqs) + tmp1 = strchr(tmp0, ':'); } + for (i = nfreqs; i < MAX_CHANNELS; i++) + bat->target_freq[i] = bat->target_freq[i % nfreqs]; } static void get_format(struct bat *bat, char *optarg) @@ -302,6 +316,7 @@ _("Usage: bat [-options]...\n" static void set_defaults(struct bat *bat) { + int i; memset(bat, 0, sizeof(struct bat)); /* Set default values */ @@ -313,8 +328,8 @@ static void set_defaults(struct bat *bat) bat->convert_float_to_sample = convert_float_to_int16; bat->convert_sample_to_double = convert_int16_to_double; bat->frames = bat->rate * 2; - bat->target_freq[0] = 997.0; - bat->target_freq[1] = 997.0; + for (i = 0; i < MAX_CHANNELS; i++) + bat->target_freq[i] = 997.0; bat->sigma_k = 3.0; bat->playback.device = NULL; bat->capture.device = NULL; diff --git a/bat/common.h b/bat/common.h index c04452d..6d5e46e 100644 --- a/bat/common.h +++ b/bat/common.h @@ -30,7 +30,7 @@ #define WAV_DATA COMPOSE('d', 'a', 't', 'a') #define WAV_FORMAT_PCM 1 /* PCM WAVE file encoding */ -#define MAX_CHANNELS 2 +#define MAX_CHANNELS 64 #define MIN_CHANNELS 1 #define MAX_PEAKS 10 #define MAX_FRAMES (10 * 1024 * 1024)