BruteFIR Control Scripts
From DRC
bfircli
bfircli is a perl script for controlling BruteFIR via its cli telnet port. It allows a user to switch filter coefficients by reading input from the command line and indicates the currently selected filter in a form that should be visible from the listening position.
#!/usr/bin/perl
# ******************************************************************************
# bfircli.pl Control BruteFIR via its Telnet port.
# Copyright (C) 2005 Neil J Mackie
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
# You can contact the author on Internet at the following address:
# bfircli at mackiefamily.net
# ******************************************************************************
# WHAT YOU NEED TO RUN IT
# This is a perl script so you will need perl to run it.
# You will also need the perl module Net::Telnet .
#
# You will also need Brutefir configured with the 'cli' module,
# see the Brutefir documentation for details.
# ******************************************************************************
# WHAT & HOW TO CUSTOMISE
# Change the variable $bfirport to be the Telnet port the BruteFIR cli module
# is configured to use.
# If BruteFIR is running on a different machine change $bfirhost to be
# the name of the host it is running on.
# Modify the prompt() subroutine to display the options you want.
#
# The script prompts the user to enter a number within a range. The numbers
# entered causes a set of commands to be sent to BruteFIR. Your BruteFIR setup
# will determine the number of choices you want and the exact commands each
# will send. Edit the code within the while loop to match your number of choices,
# and edit the commands sent according to your BriteFIR configuration.
# The code is commented to guide you.
# ******************************************************************************
use Net::Telnet ();
use strict;
my ($bfirhost);
$bfirhost = "localhost"; # change if BruteFIR is running on a remote machine
my($bfirport);
$bfirport = 3456; # change to match the port number of the BruteFIR cli module
my($choice); # stores users choice
my($choices);
$choices = 5; # change to match the number of choices given
my($finished); # set true to finish
$finished = 0;
my($indicate); # set true to indicate users choice
$indicate = 1;
my($prompt); # set true to prompt
$prompt = 1;
my($status); # for status
my($t); # stores telnet object
# open the bfir cli control port
$t = Net::Telnet->new( Timeout =>10,
Prompt => '/>/',
Errmode=>'die');
$status = $t->open(Host => $bfirhost,
Port => $bfirport);
# get user input and change bfir filter till user quits
prompt();
while (!$finished && defined($choice = <STDIN>)) {
# 1 quit the program
if ($choice == 1) {
$finished = 1;
$prompt = 0;
}
# 2 assumes 2 filters 0 & 1, a stereo pair l & r
# sets coefficients to -1 (no filtering),
# attenuates both filters by 4db to equalise levels with DRC filters.
elsif ($choice == 2) {
$status = $t->cmd("cfc 0 -1; cfc 1 -1; cfoa 0 0 4; cfoa 1 1 4;");
}
# 3 assumes 2 filters 0 & 1, and two coefficients 0 & 1
# sets filter 0 with coefficient 0, sets filter 1 with coefficient 1
# sets attenuation to 0db on both filters (see choice 2).
elsif ($choice == 3) {
$status = $t->cmd("cfc 0 0; cfc 1 1; cfoa 0 0 0; cfoa 1 1 0;");
}
# 4 assumes 2 filters 0 & 1, and another set of DRC coefficients 2 & 3
# sets filter 0 with coefficient 2, sets filter 1 with coefficient 3
# sets attenuation to 0db on both filters
elsif ($choice == 4) {
$status = $t->cmd("cfc 0 2; cfc 1 3; cfoa 0 0 0; cfoa 1 1 0;");
}
# 5 assumes 2 filters 0 & 1, and another set of DRC coefficients 4 & 5
# sets filter 0 with coefficient 4, sets filter 1 with coefficient 5
# sets attenuation to 0db on both filters
elsif ($choice == 5) {
$status = $t->cmd("cfc 0 4; cfc 1 5; cfoa 0 0 0; cfoa 1 1 0;");
}
# choice is outwith the range, indicate to user and exit
else {
$finished = 1;
$indicate = 0;
$prompt = 0;
}
if ($indicate) { indicate($choice); }
if ($prompt) { prompt(); }
}
$status = $t->cmd("quit");
$t->close;
# indicate - give a visual indication of the first parameter.
# $_[0] number to indicate on the screen, in range 1-$choices .
sub indicate {
my ($i); my ($j); my ($k);
for ($i = 1; $i <= $choices; $i++)
{
for ($j = 1; $j < $_[0]; $j++) {
print(" ");
}
for ($k = 1; $k <= $_[0]; $k++) {
print(" #");
}
print("\n");
}
}
# prompt - output the user options.
# change to match your number of choices and the names you give them.
sub prompt {
print("1) quit bfircli\n");
print("2) nofilter\n");
print("3) normal\n");
print("4) strong\n");
print("5) extreme\n");
}
# end bfircli.pl
