From owner-freebsd-questions@FreeBSD.ORG Thu Dec 31 20:11:23 2009 Return-Path: Delivered-To: freebsd-questions@FreeBSD.ORG Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1135D1065679 for ; Thu, 31 Dec 2009 20:11:23 +0000 (UTC) (envelope-from kline@thought.org) Received: from ethic.thought.org (plato.thought.org [209.180.213.209]) by mx1.freebsd.org (Postfix) with ESMTP id A85948FC24 for ; Thu, 31 Dec 2009 20:11:22 +0000 (UTC) Received: from thought.org (tao.thought.org [10.47.0.250]) (authenticated bits=0) by ethic.thought.org (8.14.3/8.14.3) with ESMTP id nBVKBH0r005501; Thu, 31 Dec 2009 12:11:17 -0800 (PST) (envelope-from kline@thought.org) Received: by thought.org (nbSMTP-1.00) for uid 1002 kline@thought.org; Thu, 31 Dec 2009 12:11:17 -0800 (PST) Date: Thu, 31 Dec 2009 12:11:17 -0800 From: Gary Kline To: Lowell Gilbert Message-ID: <20091231201117.GB3733@thought.org> References: <20091231093637.GA1832@thought.org> <447hs3kmco.fsf@be-well.ilk.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <447hs3kmco.fsf@be-well.ilk.org> User-Agent: Mutt/1.4.2.3i X-Organization: Thought Unlimited. Public service Unix since 1986. X-Of_Interest: With 23 years of service to the Unix community. X-Spam-Status: No, score=-4.4 required=3.6 tests=ALL_TRUSTED,BAYES_00 autolearn=failed version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on ethic.thought.org Cc: FreeBSD Mailing List Subject: Re: is there a way to convert an audio file into a char array? X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 31 Dec 2009 20:11:23 -0000 On Thu, Dec 31, 2009 at 01:52:07PM -0500, Lowell Gilbert wrote: > Gary Kline writes: > > > In working toward my goal of writing a keyboard driver with builtin > > clicks, I'm investigating different angles. One would be to find > > existing audio files and catting then thru /dev/dsp. > > > > Is there a way of turning any audio file/format into a character > > array---in the way that a graphic can be turned into a character > > array? > > > > For example, I turned the graphic of a small arrow to the following: > > > > unsigned char uparrow_bits[] = { > > 0x80, 0x01, 0xc0, 0x03, 0xe0, 0x07, 0xf0, 0x0f, 0xf8, 0x1f, 0xfc, 0x3f, > > 0xfe, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x1f, 0xf8, 0x1f, 0xf8, 0x1f}; > > > > Are there tools to do the same with a .au or .wav file? > > od(1), but that would be silly. Just have your program open the file > and read it in. > Yeah, I views the file with od -c; but wouldn't it be much faster to have the data file part of my test program than having to open, read, cat thru /dev/dsp each time, close file? I stole the cat from the K&R book, and by reading the click.h data file it seems everything would go much faster. (I have three actual keyboard click drivers that I'm paring down, just wondering in my pre-built click file wouldn't be a better option. It's got a seriously beautiful waveform. > -- > Lowell Gilbert, embedded/networking software engineer, Boston area > http://be-well.ilk.org/~lowell/ -- Gary Kline kline@thought.org http://www.thought.org Public Service Unix http://jottings.thought.org http://transfinite.thought.org The 7.79a release of Jottings: http://jottings.thought.org/index.php