From owner-freebsd-questions@FreeBSD.ORG Thu Dec 31 21:40:06 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 AFA5C1065676 for ; Thu, 31 Dec 2009 21:40:06 +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 686268FC08 for ; Thu, 31 Dec 2009 21:40:06 +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 nBVLdtYp006111; Thu, 31 Dec 2009 13:39:55 -0800 (PST) (envelope-from kline@thought.org) Received: by thought.org (nbSMTP-1.00) for uid 1002 kline@thought.org; Thu, 31 Dec 2009 13:39:55 -0800 (PST) Date: Thu, 31 Dec 2009 13:39:55 -0800 From: Gary Kline To: Roland Smith Message-ID: <20091231213955.GC3733@thought.org> References: <20091231093637.GA1832@thought.org> <447hs3kmco.fsf@be-well.ilk.org> <20091231201117.GB3733@thought.org> <20091231204433.GA48113@slackbox.xs4all.nl> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20091231204433.GA48113@slackbox.xs4all.nl> 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=-2.6 required=3.6 tests=ALL_TRUSTED,BAYES_00, J_CHICKENPOX_12, J_CHICKENPOX_21, J_CHICKENPOX_54 autolearn=no version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on ethic.thought.org Cc: Lowell Gilbert , 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 21:40:06 -0000 On Thu, Dec 31, 2009 at 09:44:33PM +0100, Roland Smith wrote: > On Thu, Dec 31, 2009 at 12:11:17PM -0800, Gary Kline wrote: > > > > 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. > > Just read them all once, at start-up and store them in a buffer. You could use > mmap(2), but if the sound fragments are small, that might be a waste of memory > becasue mmap maps at least a page. Well, Lowell's thinking right be dead-on if this were just for my own use, but considering that I found 3 unix-type click-drivers, this "need," however limited, exists. Below are a few of the misc noise files I've collected over the years. I'm not that famaliar with mmap, but below are the click files I have so far. the Sun's are a flat, Klick. It's a dull thud-like sound while the other one, click.* are a nice, solid thunk. There is a trailing fuzz in the after-echo. that hopefully I'll be able to edit out. Then it will be the thunk with a brief after-echo. The Sun produces a brief 0.1s BUMP, the click is this neat 0.2 thunk.... This is full-audio [koff-koff]; I'll play around with MP3 and see if the resulting click.wave can be shortened. It occured to me than this click might be too slow for a touch-typist who can do 80 or 120wpm. Or anyone who can do up to 40-60wpm. But then, you are probably watching the screen, not the keyboard. Can easily see if you've hit the key(s). 2 -rw-r--r-- 1 kline wheel 914 Sep 4 2005 Klick.au 2 -rw-r--r-- 1 kline wheel 1808 Dec 31 01:15 Klick.wav 2 -rw-r--r-- 1 kline wheel 1263 Sep 16 1997 click.au 2 -rw-r--r-- 1 kline wheel 1275 Sep 16 1997 click.wav If I had thought of this use-prefab clicks back in 1999 rather than the BEL, problem solving. ...Still, my disk crashed the following morning, so it ---- well, whatever:_) > > I'll send you a utility function I've written to read files into memory off-list. > Super, thanks, gary > Roland > -- > R.F.Smith http://www.xs4all.nl/~rsmith/ > [plain text _non-HTML_ PGP/GnuPG encrypted/signed email much appreciated] > pgp: 1A2B 477F 9970 BA3C 2914 B7CE 1277 EFB0 C321 A725 (KeyID: C321A725) -- 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