本文整理汇总了C++中sf_seek函数的典型用法代码示例。如果您正苦于以下问题:C++ sf_seek函数的具体用法?C++ sf_seek怎么用?C++ sf_seek使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sf_seek函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: soundfile_count_samples
long soundfile_count_samples(void)
{
sf_count_t curr = sf_seek(sndfile, 0, SEEK_SET|SFM_READ);
sf_count_t rc = sf_seek(sndfile, 0, SEEK_END|SFM_READ);
sf_seek(sndfile, curr, SEEK_SET|SFM_READ);
return rc;
}
开发者ID:AlisterH,项目名称:gwc,代码行数:7,代码来源:soundfile.c
示例2: free
int SoundStream::allocateDataStructures() {
int status = PV::HyPerLayer::allocateDataStructures();
free(clayer->V);
clayer->V = NULL;
// Point to clayer data struct
soundData = clayer->activity->data;
assert(soundData!=NULL);
//Layer must be 1 by 1 by 1
if(getLayerLoc()->nx != 1 || getLayerLoc()->ny != 1){
fprintf(stderr, "SoundStream::SoundStream layer must be 1 by 1 in the x and y direction\n");
exit(EXIT_FAILURE);
}
if(getLayerLoc()->nf > fileHeader->channels){
fprintf(stderr, "SoundStream::Audio file has %d channels, while the number of features is %d\n", fileHeader->channels, getLayerLoc()->nf);
exit(EXIT_FAILURE);
}
//Allocate read buffer based on number of channels
soundBuf = (float*) malloc(sizeof(float) * fileHeader->channels);
if(frameStart <= 1){
frameStart = 1;
}
//Set to frameStart, which is 1 indexed
sf_seek(fileStream, frameStart-1, SEEK_SET);
status = updateState(0,parent->getDeltaTime());
//Reset filepointer to reread the same frame on the 0th timestep
sf_seek(fileStream, frameStart-1, SEEK_SET);
return status;
}
开发者ID:PetaVision,项目名称:Projects,代码行数:29,代码来源:SoundStream.cpp
示例3: file_buffer_worker
void file_buffer_worker(void *ctx)
{
AudioFile::pimpl *fileImpl = (AudioFile::pimpl *)ctx;
int writeBuffer = (fileImpl->currentBufIndex == 0) ? 1 : 0;
sf_seek(fileImpl->sndfile, fileImpl->framesBuffered, SF_SEEK_SET);
size_t read = sf_readf_float(fileImpl->sndfile, fileImpl->bufs[writeBuffer], FRAMES_PER_FILE_BUFFER);
fileImpl->framesBuffered += read;
if (read < FRAMES_PER_FILE_BUFFER)
{
if (fileImpl->looping)
{
sf_seek(fileImpl->sndfile, 0, SF_SEEK_SET);
size_t samplesDidRead = read * fileImpl->sfInfo.channels;
size_t framesToRead = (FRAMES_PER_FILE_BUFFER - read);
sf_readf_float(fileImpl->sndfile, &(fileImpl->bufs[writeBuffer][samplesDidRead]), framesToRead);
fileImpl->framesBuffered = framesToRead;
}
else
{
fileImpl->needsBuffer = false;
}
}
fileImpl->isBuffering = false;
}
开发者ID:lukehabermehl,项目名称:blockdsp,代码行数:25,代码来源:autil_file.cpp
示例4: test_read_write_position_or_die
void
test_read_write_position_or_die (SNDFILE *file, int line_num, int pass, sf_count_t read_pos, sf_count_t write_pos)
{ sf_count_t pos ;
/* Check the current read position. */
if (read_pos >= 0 && (pos = sf_seek (file, 0, SEEK_CUR | SFM_READ)) != read_pos)
{ printf ("\n\nLine %d ", line_num) ;
if (pass > 0)
printf ("(pass %d): ", pass) ;
printf ("Read position (%ld) should be %ld.\n", SF_COUNT_TO_LONG (pos), SF_COUNT_TO_LONG (read_pos)) ;
exit (1) ;
} ;
/* Check the current write position. */
if (write_pos >= 0 && (pos = sf_seek (file, 0, SEEK_CUR | SFM_WRITE)) != write_pos)
{ printf ("\n\nLine %d", line_num) ;
if (pass > 0)
printf (" (pass %d)", pass) ;
printf (" : Write position (%ld) should be %ld.\n",
SF_COUNT_TO_LONG (pos), SF_COUNT_TO_LONG (write_pos)) ;
exit (1) ;
} ;
return ;
} /* test_read_write_position */
开发者ID:ruthmagnus,项目名称:audacity,代码行数:25,代码来源:utils.c
示例5: xmms_sndfile_seek
static gint64
xmms_sndfile_seek (xmms_xform_t *xform, gint64 samples,
xmms_xform_seek_mode_t whence, xmms_error_t *error)
{
xmms_sndfile_data_t *data;
gint64 ret = -1;
g_return_val_if_fail (xform, -1);
g_return_val_if_fail (samples >= 0, -1);
g_return_val_if_fail (whence == XMMS_XFORM_SEEK_SET ||
whence == XMMS_XFORM_SEEK_CUR ||
whence == XMMS_XFORM_SEEK_END, -1);
data = xmms_xform_private_data_get (xform);
g_return_val_if_fail (data, -1);
switch ( whence ) {
case XMMS_XFORM_SEEK_SET:
ret = sf_seek (data->sndfile, samples, SEEK_SET);
break;
case XMMS_XFORM_SEEK_CUR:
ret = sf_seek (data->sndfile, samples, SEEK_CUR);
break;
case XMMS_XFORM_SEEK_END:
ret = sf_seek (data->sndfile, samples, SEEK_END);
break;
}
return ret;
}
开发者ID:mantaraya36,项目名称:xmms2-mantaraya36,代码行数:29,代码来源:sndfile.c
示例6: readBlockAroundPoint
void readBlockAroundPoint (int xPos, int halfXapp, int* curXapp, int* leftShift) {
int startX = xPos - halfXapp;
int ix, id, ida, iz, ind, dataShift, tracesShift, pointsNumToRead;
size_t startPos;
float *ptrToTrace, *ptrToTraceSq, *ptrFrom, *ptrTo, *ptrSqFrom, *ptrSqTo;
/* check if the apperture is adequate... if not - correct it and the start point */
checkBoundary (&startX, curXapp);
*leftShift = xPos - startX;
pointsNumToRead = dagSize_ * (*curXapp);
ptrToDags_ = sf_floatalloc (pointsNumToRead);
ptrToDagsSq_ = sf_floatalloc (pointsNumToRead);
memset (ptrToDags_, 0, pointsNumToRead * sizeof (float));
memset (ptrToDagsSq_, 0, pointsNumToRead * sizeof (float));
ptrToData_ = sf_floatalloc (pointsNumToRead);
ptrToDataSq_ = sf_floatalloc (pointsNumToRead);
memset (ptrToData_, 0, pointsNumToRead * sizeof (float));
memset (ptrToDataSq_, 0, pointsNumToRead * sizeof (float));
startPos = (size_t) startX * dagSize_ * sizeof (float);
sf_seek (inDags_, startPos, SEEK_SET);
sf_seek (inDagsSq_, startPos, SEEK_SET);
sf_floatread (ptrToData_, pointsNumToRead, inDags_);
sf_floatread (ptrToDataSq_, pointsNumToRead, inDagsSq_);
/* substacking in the x-dip direction */
for (ix = 0; ix < *curXapp; ++ix) {
for (id = 0; id < dipNum_; ++id) {
tracesShift = ix * dipNum_ + id;
ptrToTrace = ptrToDags_ + tracesShift * zNum_;
ptrToTraceSq = ptrToDagsSq_ + tracesShift * zNum_;
for (ida = 0; ida < xdipapp_; ++ida) {
ind = id - xdipapp_ / 2 + ida;
if (ind < 0 || ind >= dipNum_) continue;
dataShift = ix * dipNum_ + ind;
ptrFrom = ptrToData_ + dataShift * zNum_;
ptrSqFrom = ptrToDataSq_ + dataShift * zNum_;
ptrTo = ptrToTrace;
ptrSqTo = ptrToTraceSq;
for (iz = 0; iz < zNum_; ++iz, ++ptrTo, ++ptrSqTo, ++ptrFrom, ++ptrSqFrom) {
*ptrTo += *ptrFrom;
*ptrSqTo += *ptrSqFrom;
}
}
}
}
return;
}
开发者ID:1014511134,项目名称:src,代码行数:60,代码来源:Mcrssemb.c
示例7: soundfile_insert_samples
/* insert 'sample_count' samples at sample 'insert_pos'
* to the soundfile.
* 'insert_pos' == -1 means append to end of file.
*/
int soundfile_insert_samples(long linsert_pos, long lsample_count,
int *sample_data, int status_info)
{
sf_count_t insert_pos = linsert_pos;
sf_count_t sample_count = lsample_count;
sf_count_t end_pos = sf_seek(sndfile, 0, SEEK_END|SFM_READ);
if (insert_pos < 0 || insert_pos > end_pos)
insert_pos = end_pos;
if (soundfile_shift_samples_right(insert_pos, sample_count, status_info) < 0) {
return -1;
}
/* go to insert position 'insert_pos'... */
if (sf_seek(sndfile, insert_pos, SEEK_SET|SFM_WRITE) < 0) {
perr("soundfile_insert_samples: sf_seek write pointer");
warning("Libsndfile reports write pointer seek error in audio file");
return -1;
}
/* ...and insert new data */
if (sf_writef_int(sndfile, sample_data, sample_count) != sample_count) {
perr("soundfile_insert_samples: append with sf_writef_int");
warning("Libsndfile reports write error in audio file");
return -1;
}
return 0;
}
开发者ID:AlisterH,项目名称:gwc,代码行数:33,代码来源:soundfile.c
示例8: sf_seek
int Soundfile::mixFrames(double *inputFrames, int samples, double *mixedFrames)
{
size_t position = sf_seek(sndfile, 0, SEEK_CUR);
sf_readf_double(sndfile, mixedFrames, samples);
for (int i = 0; i < samples; i++) {
mixedFrames[i] += inputFrames[i];
}
sf_seek(sndfile, position, SEEK_SET);
return sf_writef_double(sndfile, mixedFrames, samples);
}
开发者ID:BlakeJarvis,项目名称:csound,代码行数:10,代码来源:Soundfile.cpp
示例9: shot_image_stack
void shot_image_stack(float *img,float mig_min_x,float mig_min_y,int mig_nx,int mig_ny,sf_file tag,
struct shot_image_par_type image_par)
/*< stack image >*/
{
float *tmp_img;
float img_min_x,img_max_x,img_min_y,img_max_y,img_dx,img_dy;
float mig_max_x,rite_min_x,rite_max_x;
int img_ny,img_nx,rite_nx;
int n_hy_hx,img_nhx,img_nhy,nz;
int ntmp_img[2],nimg[3];
int rite_ix_b,array_ix_b;
int block_size,block_i;
int iy,rite_iy,ix,i_hy_hx,iz;
img_min_x=image_par.min_x; img_max_x=image_par.max_x; img_min_y=image_par.min_y; img_max_y=image_par.max_y;
img_dx=image_par.dx; img_dy=image_par.dy; img_ny=image_par.ny; img_nx=image_par.nx;
img_nhx=image_par.nhx; img_nhy=image_par.nhy; nz=image_par.nz;
mig_max_x=((float)(mig_nx-1))*img_dx+mig_min_x;
rite_min_x=SF_MAX(img_min_x,mig_min_x);
rite_max_x=SF_MIN(img_max_x,mig_max_x);
rite_nx=(rite_max_x-rite_min_x)/img_dx+1;
n_hy_hx= img_nhy*img_nhx; d3(n_hy_hx,nz,ntmp_img); d4(mig_ny,mig_nx,n_hy_hx,nimg);
if (rite_nx >=1){
rite_ix_b= (rite_min_x-img_min_x)/img_dx;
array_ix_b=(rite_min_x-mig_min_x)/img_dx;
tmp_img=sf_floatalloc(rite_nx*n_hy_hx*nz);
block_size=4*n_hy_hx*nz;
for(iy=0;iy<mig_ny;iy++){
vector_value_f(tmp_img,0.0,rite_nx*n_hy_hx*nz);
rite_iy= iy+(mig_min_y-img_min_y)/img_dy;
if (rite_iy < img_ny && rite_iy>= 0){
block_i=rite_iy*img_nx+rite_ix_b;
sf_seek(tag,block_i*block_size,SEEK_SET);
sf_floatread(tmp_img,rite_nx*n_hy_hx*nz,tag);
for(ix=0;ix<rite_nx;ix++){
for(i_hy_hx=0;i_hy_hx<n_hy_hx;i_hy_hx++){
for(iz=0;iz<nz;iz++){
tmp_img[i3(ix,i_hy_hx,iz,ntmp_img)]+=img[i4(iz,iy,array_ix_b+ix,i_hy_hx,nimg)];
}
}
}
sf_seek(tag,block_i*block_size,SEEK_SET);
sf_floatwrite(tmp_img,rite_nx*n_hy_hx*nz,tag);
}
}
free(tmp_img);
}
}
开发者ID:1014511134,项目名称:src,代码行数:52,代码来源:image.c
示例10: DEBUG_ASSERT
SINT SoundSourceSndFile::seekSampleFrame(
SINT frameIndex) {
DEBUG_ASSERT(isValidFrameIndex(frameIndex));
const sf_count_t seekResult = sf_seek(m_pSndFile, frameIndex, SEEK_SET);
if (0 <= seekResult) {
return seekResult;
} else {
qWarning() << "Failed to seek libsnd file:" << seekResult
<< sf_strerror(m_pSndFile);
return sf_seek(m_pSndFile, 0, SEEK_CUR);
}
}
开发者ID:PetrBarborka,项目名称:mixxx,代码行数:13,代码来源:soundsourcesndfile.cpp
示例11: m_file
WavFileReadStream::WavFileReadStream(string path) :
m_file(0),
m_path(path),
m_offset(0)
{
m_channelCount = 0;
m_sampleRate = 0;
m_fileInfo.format = 0;
m_fileInfo.frames = 0;
m_file = sf_open(m_path.c_str(), SFM_READ, &m_fileInfo);
if (!m_file || m_fileInfo.frames <= 0 || m_fileInfo.channels <= 0) {
cerr << "WavFileReadStream::initialize: Failed to open file \""
<< path << "\" (" << sf_strerror(m_file) << ")" << endl;
if (sf_error(m_file) == SF_ERR_SYSTEM) {
m_error = string("Couldn't load audio file '") +
m_path + "':\n" + sf_strerror(m_file);
throw FileNotFound(m_path);
}
if (m_file) {
m_error = string("Couldn't load audio file '") +
m_path + "':\n" + sf_strerror(m_file);
} else {
m_error = string("Failed to open audio file '") +
m_path + "'";
}
throw InvalidFileFormat(m_path, m_error);
}
m_channelCount = m_fileInfo.channels;
m_sampleRate = m_fileInfo.samplerate;
sf_seek(m_file, 0, SEEK_SET);
}
开发者ID:breakfastquay,项目名称:bqaudiostream,代码行数:35,代码来源:WavFileReadStream.cpp
示例12: wxASSERT
bool BlockFile::OpenReadData()
{
wxASSERT(mMode == BLOCK_MODE_NOT_OPEN);
if (mType == BLOCK_TYPE_ALIAS) {
mInfo = (void *)new SF_INFO;
mSoundFile = (void *)sf_open_read(mAliasFullPath, (SF_INFO *)mInfo);
if (mSoundFile != 0) {
sf_seek((SNDFILE *)mSoundFile, mStart, SEEK_SET);
mMode = BLOCK_MODE_READ_DATA;
mPos = WaveTrack::GetHeaderLen();
return true;
}
return false;
} else {
mFile = new wxFFile();
bool success = mFile->Open((const wxChar *) mFullPath, "rb");
if (success) {
mMode = BLOCK_MODE_READ_DATA;
SeekTo(0); /* seek to the beginning of the data area */
}
return success;
}
}
开发者ID:andreipaga,项目名称:audacity,代码行数:28,代码来源:BlockFile.cpp
示例13: RUNTIME_ERROR
unsigned AudioFileSndfile::seek(int pos, IAudioFile::SeekWhence sw,
IAudioFile::SeekType st)
{
if (!_info.seekable || !_handle) {
RUNTIME_ERROR("File not seekable or handle not open");
}
static int whenceMap[3] = {
SF_SEEK_CUR,
SF_SEEK_END,
SF_SEEK_SET,
};
int whence = whenceMap[sw];
if (SeekTypeRead == st) {
whence |= SFM_READ;
} else if (SeekTypeWrite == st) {
whence |= SFM_WRITE;
}
sf_count_t result = sf_seek(_handle.get(), pos, whence);
if (result < 0) {
int errorNumber = sf_error(_handle.get());
SNDFILE_ERROR(errorNumber, "Unable to seek file");
}
return unsigned(result);
}
开发者ID:aasfalcon,项目名称:wexplorer,代码行数:30,代码来源:audiofilesndfile.cpp
示例14: sf_close
int OlaRandom::ReadSoundFile( char filename[] )
{
// open file
if( sfread )
{
sf_close( sfread );
}
sfread = sf_open( filename, SFM_READ, &readinfo );
if( !sfread )
{
BB_log( BB_LOG_SEVERE, "[TreesynthIO]: Could not open input file '%s', %s",
filename, sf_error_number( sf_error( sfread ) ) );
return 0;
}
strcpy( ifilename, filename );
// determine number of buffers needed
origsize = readinfo.frames;
std::cerr << "frames: " << origsize << std::endl;
SAFE_DELETE_ARRAY(origbuffer);
origbuffer = new float[origsize];
// read
sf_seek( sfread, 0, SEEK_SET );
int itemsread = sf_read_float( sfread, origbuffer, origsize);
sf_close( sfread );
sfread = NULL;
return itemsread;
}
开发者ID:alltom,项目名称:taps,代码行数:30,代码来源:Ola.cpp
示例15: return
DWORD ISndStreamWAV::GetCurrentTime()
{
// return total time in ms
if (GetSampleRate()>0)
return (DWORD)sf_seek( m_pSndFile, 0, SEEK_CUR )/GetSampleRate()*1000;
return 0;
}
开发者ID:joshlong,项目名称:libcd,代码行数:7,代码来源:ISndStreamWav.cpp
示例16: sndfile_stream_decode
static void
sndfile_stream_decode(struct decoder *decoder, struct input_stream *is)
{
GError *error = NULL;
SNDFILE *sf;
SF_INFO info;
struct audio_format audio_format;
size_t frame_size;
sf_count_t read_frames, num_frames;
int buffer[4096];
enum decoder_command cmd;
info.format = 0;
sf = sf_open_virtual(&vio, SFM_READ, &info, is);
if (sf == NULL) {
g_warning("sf_open_virtual() failed");
return;
}
/* for now, always read 32 bit samples. Later, we could lower
MPD's CPU usage by reading 16 bit samples with
sf_readf_short() on low-quality source files. */
if (!audio_format_init_checked(&audio_format, info.samplerate,
SAMPLE_FORMAT_S32,
info.channels, &error)) {
g_warning("%s", error->message);
g_error_free(error);
return;
}
decoder_initialized(decoder, &audio_format, info.seekable,
frame_to_time(info.frames, &audio_format));
frame_size = audio_format_frame_size(&audio_format);
read_frames = sizeof(buffer) / frame_size;
do {
num_frames = sf_readf_int(sf, buffer, read_frames);
if (num_frames <= 0)
break;
cmd = decoder_data(decoder, is,
buffer, num_frames * frame_size,
0);
if (cmd == DECODE_COMMAND_SEEK) {
sf_count_t c =
time_to_frame(decoder_seek_where(decoder),
&audio_format);
c = sf_seek(sf, c, SEEK_SET);
if (c < 0)
decoder_seek_error(decoder);
else
decoder_command_finished(decoder);
cmd = DECODE_COMMAND_NONE;
}
} while (cmd == DECODE_COMMAND_NONE);
sf_close(sf);
}
开发者ID:OpenInkpot-archive,项目名称:iplinux-mpd,代码行数:60,代码来源:sndfile_decoder_plugin.c
示例17: Flush
__int64 ISndStreamWAV::Seek( __int64 ddwOffset, UINT nFrom )
{
__int64 ddwFilePosition = 0;
int nPercent = (int)ddwOffset;
// Flush the stream
Flush();
switch ( nFrom )
{
case SEEK_PERCENT:
if ( nPercent<0 ) nPercent= 0;
if ( nPercent>99 ) nPercent=99;
ddwFilePosition= (__int64)( nPercent * m_ddwTotalFileSize / 100.0 );
break;
case SEEK_TIME:
ddwFilePosition= (__int64)( ddwOffset / 1000.0 * GetSampleRate() );
break;
default:
ASSERT( FALSE );
break;
}
ddwFilePosition = ddwFilePosition / 4 * 4;
// Seek to the desired position
sf_seek( m_pSndFile, ddwFilePosition, SEEK_SET );
return ddwFilePosition;
}
开发者ID:joshlong,项目名称:libcd,代码行数:31,代码来源:ISndStreamWav.cpp
示例18: sf_open
//-----------------------------------------------------------------------------
// name: int ReadSoundFile( char filename[], TS_FLOAT * data, int datasize )
// desc: Reads given sound file into data array
//-----------------------------------------------------------------------------
int TreesynthIO::ReadSoundFile( char filename[], TS_FLOAT * data, int datasize )
{
if( !sfread ) {
sfread = sf_open( filename, SFM_READ, &info );
if( !sfread )
{
std::cerr << "TreesynthIO::ReadSoundFile : cannot open file '" << filename << "', quitting" << std::endl;
char x[256];
std::cin.getline( x, 256 );
exit(1);
}
}
datasize = rm_next_length;
sf_seek( sfread, rm_next_pos, SEEK_SET );
std::cerr << sfread << " " << data << " " << datasize << std::endl;
int itemsread = sf_read_float( sfread, data, datasize );
set_next_pos( filename );
// rt audio
/*if( !audio_initialize( info.samplerate ) ) { // 44100
std::cerr << "TreesynthIO::ReadSoundFile : cannot open audio interface, quitting" << std::endl;
char x[256];
std::cin.getline( x, 256 );
exit(1);
}*/
return itemsread;
}
开发者ID:alltom,项目名称:taps,代码行数:32,代码来源:Eliot.cpp
示例19: seek
bool SndFileDecoder::seek(size_t ms_offset, bool ms, bool /*mayrestart*/)
{
size_t smp_offset = ms? (size_t)((double)ms_offset / 1000. * SndInfo.samplerate) : ms_offset;
if(sf_seek(SndFile, smp_offset, SEEK_SET) < 0)
return false;
return true;
}
开发者ID:ArcticPheenix,项目名称:gzdoom,代码行数:7,代码来源:sndfile_decoder.cpp
示例20: readsoundfilechunk
soundfile * readsoundfilechunk(char *path, int start, int len) {
soundfile * ret;
SF_INFO info;
SNDFILE *snd;
memset(&info, 0, sizeof(info));
if ( (snd = sf_open(path, SFM_READ, &info)) == NULL )
diem("Couldn't open sound file for reading", path);
if ( info.channels != 1 )
diem("Sound file has more than one channel", path);
if ( (ret = malloc(sizeof(*ret))) == NULL )
die("Couldn't malloc space for soundfile");
if ( (ret->data = malloc(sizeof(float)*len)) == NULL )
die("Couldn't malloc space for sound buffer");
sf_seek(snd, start, SEEK_SET);
int actuallen = sf_read_float(snd, ret->data, len); // assumption: channel count is 1, verified above
ret->length = actuallen;
ret->samplerate = info.samplerate;
if ( sf_close(snd) )
diem("Couldn't close sound file", path);
return ret;
}
开发者ID:encryptio,项目名称:convolute,代码行数:30,代码来源:readsoundfile.c
注:本文中的sf_seek函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论