⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 libst.3

📁 linux下录音程序
💻 3
字号:
.de Sh.br.ne 5.PP\fB\\$1\fR.PP...de Sp.if t .sp .5v.if n .sp...TH ST 3 "October 15 1996".SH NAMElibst \- Sound Tools : sound sample file and effects libraries..SH SYNOPSIS.B cc \fIfile.c\fB -o \fIfile \fBlibst.a.SH DESCRIPTION.I Sound\ Toolsis a library of sound sample file format readers/writersand sound effects processors..PSound Tools includes skeleton Cfiles to assist you in writing new formats and effects.  The full skeleton driver, skel.c, helps you write drivers for a new format which has data structures.  The simple skeleton drivershelp you write a new driver for raw (headerless) formats, orfor formats which just have a simple header followed by raw data..PMost sound sample formats are fairly simple: they are just a stringof bytes or words and are presumed to be sampled at a known data rate.Most of them have a short data structure at the beginning of the file..SH INTERNALSThe Sound Tools formats and effects operate on an internal buffer formatof signed 32-bit longs.The data processing routines are called with buffers of thesesamples, and buffer sizes which refer to the number of samplesprocessed, not the number of bytes.File readers translate the input samples to signed longsand return the number of longs read.For example, data in linear signed byte format is left-shifted 24 bits..PThis does cause problems in processing the data.  For example:.br	*obuf++ = (*ibuf++ + *ibuf++)/2;.brwould.I notmix down left and right channels into one monophonic channel,because the resulting samples would overflow 32 bits.Instead, the ``avg'' effects must use:.br	*obuf++ = *ibuf++/2 + *ibuf++/2;.br.PStereo data is stored with the left and right speaker data insuccessive samples.Quadraphonic data is stored in this order: left front, right front, left rear, right rear..SH FORMATSA .I format is responsible for translating between sound sample filesand an internal buffer.  The internal buffer is store in signed longswith a fixed sampling rate.  The .I formatoperates from two data structures:a format structure, and a private structure..PThe format structure contains a list of control parameters forthe sample: sampling rate, data size (bytes, words, floats, etc.),style (unsigned, signed, logarithmic), number of sound channels.It also contains other state information: whether the sample fileneeds to be byte-swapped, whether fseek() will work, its suffix,its file stream pointer, its .I formatpointer, and the .I privatestructure for the .I format ..PThe .I private area is just a preallocated data array for the .I formatto use however it wishes.  It should have a defined data structureand cast the array to that structure.  See voc.c for the use of a private data area.  Voc.c has to track the number of samples it writes and when finishing, seek back to the beginning of the fileand write it out.The private area is not very large.The ``echo'' effect has to malloc() a much larger area for itsdelay line buffers..PA .I formathas 6 routines:.TP 20startreadSet up the format parameters, or read ina data header, or do what needs to be done..TP 20readGiven a buffer and a length: read up to that many samples, transform them into signed long integers,and copy them into the buffer.Return the number of samples actually read..TP 20stopreadDo what needs to be done..TP 20startwriteSet up the format parameters, or write out a data header, or do what needs to be done..TP 20writeGiven a buffer and a length: copy that many samples out of the buffer,convert them from signed longs to the appropriatedata, and write them to the file.If it can't write out all the samples,fail..TP 20stopwriteFix up any file header, or do what needs to be done..SH EFFECTSAn effects loop has one input and one output stream.It has 5 routines..TP 20getoptsis called with a character string argument list for the effect..TP 20startis called with the signal parameters for the input and outputstreams..TP 20 flowis called with input and output data buffers,and (by reference) the input and output data sizes.It processes the input buffer into the output buffer,and sets the size variables to the numbers of samplesactually processed.It is under no obligation to fill the output buffer..TP 20 drainis called after there are no more input data samples.If the effect wishes to generate more data samplesit copies the generated data into a given bufferand returns the number of samples generated.If it fills the buffer, it will be called again, etc.The echo effect uses this to fade away..TP 20stopis called when there are no more input samples to process..I stopmay generate output samples on its own.See echo.c for how to do this, and see that what it does is absolutely bogus..SH COMMENTSTheoretically, formats can be used to manipulate several files inside one program.  Multi-sample files, for example the downloadfor a sampling keyboard, can be handled cleanly with this feature..SH PORTABILITY PROBLEMSMany computers don't supply arithmetic shifting, so do multipliesand divides instead of << and >>.  The compiler will do the rightthing if the CPU supplies arithmetic shifting..PDo all arithmetic conversions one stage at a time.I've had too many problems with "obviously clean" combinations..PIn general, don't worry about "efficiency".  The sox.c base translatoris disk-bound on any machine (other than a 8088 PC with an SMD disk controller).  Just comment your code and make sure it's clean and simple.You'll find that DSP code is extremely painful to write as it is..SH BUGSThe HCOM format is not re-entrant; it can only be used once in a program..PThe program/library interface is pretty weak.There's too much ad-hoc information which a program is supposed togather up.Sound Tools wants to be an object-oriented dataflow architecture.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -