Date: Thu, 30 Oct 2003 07:10:22 -0800 From: Tim Pozar <pozar@lns.com> To: Jason Cowlishaw <jasonc@cowlishaw.net> Cc: freebsd-multimedia@freebsd.org Subject: Re: Recommend fm tuner for cli only? Message-ID: <20031030151022.GA36068@lns.com> In-Reply-To: <000001c39dd2$420e43f0$1402a8c0@bushido> References: <000001c39dd2$420e43f0$1402a8c0@bushido>
next in thread | previous in thread | raw e-mail | index | archive | help
--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 <stdio.h> #include <stdlib.h> #include <fcntl.h> #include <signal.h> #include <sys/ioctl.h> #include <machine/ioctl_bt848.h> #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--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20031030151022.GA36068>