Sample(sound)
Sample()所属R语言包:sound
Sample Objects
示例对象
译者:生物统计家园网 机器人LoveR
描述----------Description----------
as.Sample creates a Sample object from a given numeric matrix.
as.Sample创建一个Sample对象从一个给定的数值矩阵。
is.Sample tests if its argument is a Sample object or the name of a wav file.
is.Sample测试,如果它的参数是一个的样本对象或一个wav文件的名称。
用法----------Usage----------
is.Sample(s, argname="'s' ")
参数----------Arguments----------
参数:sound
a channels(s) x sampleLength(s) matrix or a vector of doubles describing the waveform(s) of the sample.
一个channels(s)XsampleLength(s)矩阵或一个向量的双打描述波形(S)的样本。“
参数:rate
the sampling rate (number of samples per second).
的采样速率(每秒的样本数)。
参数:bits
the sampling quality (the number of bits per sample), 8 or 16.
采样质量(每个样本的比特数),8个或16个。
参数:s
an R object to be tested.
一个R对象来进行测试。
参数:argname
a string giving the name of the object that is tested. It is used for creating an error message.
一个字符串,给出被测试的对象,该对象的名称。它是用于创建一个错误消息。
Details
详细信息----------Details----------
The rows of the matrix represent the channels of the sample: If sound is a vector or a matrix with only one row, as.Sample will return a mono sample; if sound is a matrix with two rows, as.Sample returns a stereo sample, where the left and the right channel are represented by the first and the second row, respectively.
该矩阵的行代表的信道的示例:如果sound是矢量或矩阵只有一行,as.Sample将返回的单样本;如果sound是一个矩阵两行,as.Sample返回一个立体声采样,其中左和右信道的表示由所述第一和第二行分别。
sound can contain any real number, but when the Sample object is played or saved to disk, [-1,1] is regarded as the range of the sample, and any values outside this interval will cause cracks in the sound.
sound可以包含任意的实数,但Sample对象播放或保存到磁盘时,[-1,1]的范围内的样品被视为,和此时间间隔以外的任何值,将导致裂缝在声音。
A Sample object's waveform can exceed this interval during calculations. It is the task of the programmer to take care of the range of the waveform before saving or playing the sample, for example by using the normalize command.
在计算过程中,一个Sample对象的波形可以超过这个时间间隔。它的任务就是照顾范围的波形保存或打样品,例如,通过使用normalize命令之前,程序员。
Internally, the sound is saved as a matrix with doubles, independent of the bits parameter that is only used when the Sample object is played or saved to disk.
在内部,声音将被保存为一个矩阵,双打,独立的bits参数仅用于样本对象时,播放或保存到磁盘。
The is.Sample command is used by several other routines that allow both Sample objects and filenames as arguments.
is.Sample命令所使用的其他几个程序,让两个样本对象和文件名作为参数。
值----------Value----------
For as.Sample a Sample object, that is a list with the components $sound, $rate and $bits.
as.Sample一个Sample对象,这是一个与组件列表$sound,$rate和$bits。
is.Sample returns a list with the entries <table summary="R valueblock"> <tr valign="top"><td>test </td> <td> a logical indicating whether or not s is a Sample object or the name of a valid wav file.</td></tr> <tr valign="top"><td>error </td> <td> a string with one of the messages "Filename must have the extension .wav.", "File not found.", "No read permission for this file.", or "Argument "+ argname + "must be a Sample object or the name of a wav file." If test=TRUE, this list entry doesn't exist.</td></tr> </table>
is.Sample返回一个列表中的条目<table summary="R valueblock"> <tr valign="top"> <TD>test </ TD> <td>一个逻辑说明是否s是一个简单的对象或一个有效的wav文件的名称。</ TD> </ TR> <tr valign="top"> <TD> error </ TD> <td>一个字符串的邮件“文件名必须有扩展名。wav文件。”,“未找到文件”,“没有读取这个文件的权限。”,或“论证”+ argname +“必须是一个Sample对象的名称或一个wav文件。“如果test=TRUE,这个列表条目不存在。</ TD> </ TR> </ TABLE>
(作者)----------Author(s)----------
Matthias Heymann
参见----------See Also----------
stereo for creating a stereo Sample object from two mono Sample objects, loadSample for loading a wav file and turning it into a Sample object, saveSample for saving a Sample object as a wav file, sound, bits, rate, channels, sampleLength and duration for access to the basic parameters of a Sample object.
stereo两个单声道采样对象创建一个立体声采样对象,loadSample加载wav文件,把它变成一个Sample对象的,saveSample一个Sample对象保存为WAV文件, sound,bits,rate,channels,sampleLength和duration访问的样本对象的基本参数。
实例----------Examples----------
waveLeft <- 2*((seq(0,80,length=88200)%%1^2)-.5)
s <- as.Sample(waveLeft,44100,16)
play(s) # a mono sample[一个单样本]
waveRight <- waveLeft[88200:1]
s <- as.Sample(rbind(waveLeft,waveRight),44100,16)
play(s) # a stereo Sample[一个立体声采样]
# How to use is.Sample to allow both a Sample object and a filename[了如何使用is.Sample允许一个的Sample对象和文件名都]
# as an argument:[作为参数:]
x <- anyargument
sampletest <- is.Sample(x, argname="'x' ")
if (!sampletest$test) stop(sampletest$error) #no valid argument[没有有效的参数]
x <- loadSample(x,filecheck=FALSE)
# If x is Sample object, loadSample will return it immediately.[如果x是样本对象,loadSample将立即返回它。]
# If x is a string, the Sample object will be loaded from disk.[如果x是一个字符串,采样对象将被从磁盘加载。]
# No check for existence of the file will be performed since this[检查存在的文件会被执行,因为这]
# was already tested in is.Sample.[是已经测试is.Sample。]
#[]
# Now x is a Sample object, continue with code.[现在,x是一个Sample对象,继续与代码。]
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|