Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 31 Dec 2009 13:39:55 -0800
From:      Gary Kline <kline@thought.org>
To:        Roland Smith <rsmith@xs4all.nl>
Cc:        Lowell Gilbert <freebsd-questions-local@be-well.ilk.org>, FreeBSD Mailing List <freebsd-questions@freebsd.org>
Subject:   Re: is there a way to convert an audio file into a char array?
Message-ID:  <20091231213955.GC3733@thought.org>
In-Reply-To: <20091231204433.GA48113@slackbox.xs4all.nl>
References:  <20091231093637.GA1832@thought.org> <447hs3kmco.fsf@be-well.ilk.org> <20091231201117.GB3733@thought.org> <20091231204433.GA48113@slackbox.xs4all.nl>

next in thread | previous in thread | raw e-mail | index | archive | help
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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20091231213955.GC3733>