From owner-freebsd-multimedia@FreeBSD.ORG Thu Oct 30 07:10:28 2003 Return-Path: Delivered-To: freebsd-multimedia@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 3E4CD16A4CE for ; Thu, 30 Oct 2003 07:10:28 -0800 (PST) Received: from kumr.lns.com (kumr.lns.com [63.198.122.138]) by mx1.FreeBSD.org (Postfix) with ESMTP id 0B3DC43FE0 for ; Thu, 30 Oct 2003 07:10:27 -0800 (PST) (envelope-from pozar@kumr.lns.com) Received: from kumr.lns.com (pozar@localhost [127.0.0.1]) by kumr.lns.com (8.12.9/8.9.3) with ESMTP id h9UFAO6p060984; Thu, 30 Oct 2003 07:10:24 -0800 (PST) (envelope-from pozar@kumr.lns.com) Received: (from pozar@localhost) by kumr.lns.com (8.12.9/8.12.9/Submit) id h9UFAMJ8060978; Thu, 30 Oct 2003 07:10:22 -0800 (PST) Date: Thu, 30 Oct 2003 07:10:22 -0800 From: Tim Pozar To: Jason Cowlishaw Message-ID: <20031030151022.GA36068@lns.com> References: <000001c39dd2$420e43f0$1402a8c0@bushido> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="UlVJffcvxoiEqYs2" Content-Disposition: inline In-Reply-To: <000001c39dd2$420e43f0$1402a8c0@bushido> User-Agent: Mutt/1.4.1i cc: freebsd-multimedia@freebsd.org Subject: Re: Recommend fm tuner for cli only? X-BeenThere: freebsd-multimedia@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Multimedia discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 30 Oct 2003 15:10:28 -0000 --UlVJffcvxoiEqYs2 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Tue, Oct 28, 2003 at 10:08:01PM -0600, Jason Cowlishaw wrote: > I have a Hauppauge TV tuner w/ FM radio in a Freebsd 5.0-Rel box. I am > looking for a command line only FM tuning program. My server does not > have X installed. Can anyone recommend any programs for just the FM > tuner? I wrote my own that is attached. Tim -- Snail: Tim Pozar / LNS / 1978 45th Ave / San Francisco CA 94116 / USA POTS: +1 415 665 3790 Radio: KC6GNJ / KAE6247 "Be who you are and say what you feel because the people who mind don't matter and the people who matter don't mind." - Dr. Seuss --UlVJffcvxoiEqYs2 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="tuneradio.c" /* * * TUNERADIO * * Opens the the tuner device (ie. /dev/tuner) sets the frequency, * stereo/mono and AFC modes. It then sits in a while loop to * keep the device open. * * I needed this program to run on remote computers that stream * MP3 streams out to the net of radio stations. This program * assumes the Brooktree 848 card and interface for *BSD. * * Copyright (C) 2000 Timothy Pozar pozar@lns.com * * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * $Id: tuneradio.c,v 1.2 2000/02/22 19:20:02 pozar Exp pozar $ * */ #include #include #include #include #include #include #define TRUE 1 #define FALSE 0 #define BUF_SIZE 4096 char device[BUF_SIZE] = "/dev/tuner"; int mono = FALSE; int afc = FALSE; int frequency = 8850; /* 8850 = 88.5Mhz */ int devfh; int setaudio; static void cleanup (void); static void cntlc_handler (void); int main(argc,argv) int argc; char *argv[]; { int gotmask, setmask, gotfreq, setfreq, i; /* scan command line arguments, and look for files to work on. */ for (i = 1; i < argc; i++) { switch (argv[i][1]){ /* be case indepenent... */ case 'A': /* Run with AFC... */ case 'a': afc = TRUE; break; case 'D': /* dsp file name... */ case 'd': i++; strncpy(device,argv[i],BUF_SIZE); break; case 'F': /* Frequency in 10 KHz... */ case 'f': i++; frequency = atoi(argv[i]); if((frequency < 8800) || (frequency > 10800)){ printf("Frequency %i is out of range of 8800 to 10800\n",frequency); exit(1); } break; case 'H': /* Help... */ case 'h': banner(); exit(0); case 'M': /* Run in mono... */ case 'm': mono = TRUE; break; default: printf("I don't know the meaning of the command line argument: \"%s\".\n",argv[i]); banner(); exit(1); } } if (atexit (cleanup) == -1) perror ("atexit"); if (signal (SIGINT, cntlc_handler) == -1) { perror ("Signal INT..."); exit (1); } if (signal (SIGHUP, cntlc_handler) == -1) { perror ("Signal HUP..."); exit (1); } if((devfh = open(device, O_RDONLY)) == -1){ perror("opening dsp device"); exit(1); } setaudio = AUDIO_INTERN; if(ioctl(devfh, BT848_SAUDIO, &setaudio) == -1){ perror("set internal audio "); exit(1); } if(ioctl(devfh, RADIO_GETMODE, &gotmask) == -1){ perror("get mode"); exit(1); } setmask = gotmask; if(mono) setmask |= RADIO_MONO; else setmask &= ~RADIO_MONO; if(afc) setmask |= RADIO_AFC; else setmask &= ~RADIO_AFC; if(ioctl(devfh, RADIO_SETMODE, &setmask) == -1){ perror("set mode - mono/afc"); exit(1); } if(ioctl(devfh, RADIO_SETFREQ, &frequency) == -1){ perror("set frequency"); exit(1); } while(1){ sleep(1); } exit(0); } banner() { printf("tuneradio: Set \"%s\" frequency, AFC and stereo/mono mode,\n",device); printf(" and then keep the tuner open.\n"); printf(" -a Sets tuner to run with AFC. Default is off.\n"); printf(" -d device Sets device name for the tuner. Default is \"%s\".\n",device); printf(" -f frequency Sets tuner frequency (10Khz ie 88.1Mhz = 8810).\n"); printf(" Default is \"%i\".\n",frequency); printf(" -m Sets tuner to run in mono. Default is stereo.\n"); return; } /* * cntlc_handler() * * runs when a user does a CNTL-C... * */ void cntlc_handler () { exit (0); } /* * cleanup() * * runs on exit... * */ void cleanup () { printf ("Shutting down...\n"); setaudio = AUDIO_EXTERN; if(ioctl(devfh, BT848_SAUDIO, &setaudio) == -1){ perror("set internal audio "); } setaudio = AUDIO_UNMUTE; if(ioctl(devfh, BT848_SAUDIO, &setaudio) == -1){ perror("set unmute audio "); } close (devfh); } --UlVJffcvxoiEqYs2--