• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ sf_command函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中sf_command函数的典型用法代码示例。如果您正苦于以下问题:C++ sf_command函数的具体用法?C++ sf_command怎么用?C++ sf_command使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了sf_command函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: sf_open

// ----------------------------------------------------------------------------
bool ofOpenALSoundPlayer::sfReadFile(string path, vector<short> & buffer, vector<float> & fftAuxBuffer){
	SF_INFO sfInfo;
	SNDFILE* f = sf_open(path.c_str(),SFM_READ,&sfInfo);
	if(!f){
		ofLog(OF_LOG_ERROR,"ofOpenALSoundPlayer: couldnt read " + path);
		return false;
	}

	buffer.resize(sfInfo.frames*sfInfo.channels);
	fftAuxBuffer.resize(sfInfo.frames*sfInfo.channels);

	int subformat = sfInfo.format & SF_FORMAT_SUBMASK ;
	if (subformat == SF_FORMAT_FLOAT || subformat == SF_FORMAT_DOUBLE){
		double	scale ;
		sf_command (f, SFC_CALC_SIGNAL_MAX, &scale, sizeof (scale)) ;
		if (scale < 1e-10)
			scale = 1.0 ;
		else
			scale = 32700.0 / scale ;

		sf_count_t samples_read = sf_read_float (f, &fftAuxBuffer[0], fftAuxBuffer.size());
		if(samples_read<(int)fftAuxBuffer.size())
			ofLog(OF_LOG_ERROR,"ofOpenALSoundPlayer: couldnt read " + path);
		for (int i = 0 ; i < int(fftAuxBuffer.size()) ; i++){
			fftAuxBuffer[i] *= scale ;
			buffer[i] = 32565.0 * fftAuxBuffer[i];
		}
	}else{
		sf_count_t frames_read = sf_readf_short(f,&buffer[0],sfInfo.frames);
		if(frames_read<sfInfo.frames){
			ofLog(OF_LOG_ERROR,"ofOpenALSoundPlayer: couldnt read buffer for " + path);
			return false;
		}
		sf_seek(f,0,SEEK_SET);
		frames_read = sf_readf_float(f,&fftAuxBuffer[0],sfInfo.frames);
		if(frames_read<sfInfo.frames){
			ofLog(OF_LOG_ERROR,"ofOpenALSoundPlayer: couldnt read fft buffer for " + path);
			return false;
		}
	}
	sf_close(f);

	channels = sfInfo.channels;
	duration = float(sfInfo.frames) / float(sfInfo.samplerate);
	samplerate = sfInfo.samplerate;
	return true;
}
开发者ID:AsherBond,项目名称:openFrameworks,代码行数:48,代码来源:ofOpenALSoundPlayer.cpp


示例2: dump_log_buffer

void
dump_log_buffer (SNDFILE *file)
{	static char	buffer [LOG_BUFFER_SIZE] ;
	int			count ;

	memset (buffer, 0, LOG_BUFFER_SIZE) ;

	/* Get the log buffer data. */
	count = sf_command	(file, SFC_GET_LOG_INFO, buffer, LOG_BUFFER_SIZE) ;

	if (strlen (buffer) < 1)
		puts ("Log buffer empty.\n") ;
	else
		puts (buffer) ;

	return ;
} /* dump_log_buffer */
开发者ID:ruthmagnus,项目名称:audacity,代码行数:17,代码来源:utils.c


示例3: sf_error_number

std::string AudioFileSndfile::sndfileError(int errorNumber,
    const std::string& userMessage) const
{
    const std::string libraryMessage = sf_error_number(errorNumber);
    char logInfo[LOGINFO_MAX_SIZE];
    sf_command(_handle.get(), SFC_GET_LOG_INFO, logInfo, LOGINFO_MAX_SIZE);
    LOG(INFO,
        "Library error detailed information"
            << "\n\n"
            << "Sound file: " << _path << '\n'
            << "Library reports: " << libraryMessage << '\n'
            << "Library version: " << sf_version_string() << '\n'
            << "Library log follows:\n"
            << logInfo);

    return userMessage + ": " + libraryMessage;
}
开发者ID:aasfalcon,项目名称:wexplorer,代码行数:17,代码来源:audiofilesndfile.cpp


示例4: usage_exit

static void
usage_exit (const char *progname)
{	char lsf_ver [128] ;
	const char	*cptr ;
	int		k ;

	if ((cptr = strrchr (progname, '/')) != NULL)
		progname = cptr + 1 ;

	if ((cptr = strrchr (progname, '\\')) != NULL)
		progname = cptr + 1 ;


	sf_command (NULL, SFC_GET_LIB_VERSION, lsf_ver, sizeof (lsf_ver)) ;

	printf ("\n"
		"  A Sample Rate Converter using libsndfile for file I/O and Secret \n"
		"  Rabbit Code (aka libsamplerate) for performing the conversion.\n"
		"  It works on any file format supported by libsndfile with any \n"
		"  number of channels (limited only by host memory).\n"
		"\n"
		"       %s\n"
		"       %s\n"
		"\n"
		"  Usage : \n"
		"       %s -to <new sample rate> [-c <number>] <input file> <output file>\n"
		"       %s -by <amount> [-c <number>] <input file> <output file>\n"
		"\n", src_get_version (), lsf_ver, progname, progname) ;

	puts (
		"  The optional -c argument allows the converter type to be chosen from\n"
		"  the following list :"
		"\n"
		) ;

	for (k = 0 ; (cptr = src_get_name (k)) != NULL ; k++)
		printf ("       %d : %s%s\n", k, cptr, k == DEFAULT_CONVERTER ? " (default)" : "") ;

	puts ("\n"
		"  The --no-normalize option disables clipping check and normalization.") ;

	puts ("") ;

	exit (1) ;
} /* usage_exit */
开发者ID:jrlanglois,项目名称:SecretRabbitCode,代码行数:45,代码来源:sndfile-resample.c


示例5: main

int
main (int argc, char *argv [])
{   SNDFILE *file ;
    SF_INFO sfinfo ;
    SF_BROADCAST_INFO_2K binfo ;
    const char *progname ;
    const char * filename = NULL ;
    int	start ;

    /* Store the program name. */
    progname = program_name (argv [0]) ;

    /* Check if we've been asked for help. */
    if (argc <= 2 || strcmp (argv [1], "--help") == 0 || strcmp (argv [1], "-h") == 0)
        usage_exit (progname, 0) ;

    if (argv [argc - 1][0] != '-')
    {   filename = argv [argc - 1] ;
        start = 1 ;
    }
    else if (argv [1][0] != '-')
    {   filename = argv [1] ;
        start = 2 ;
    }
    else
    {   printf ("Error : Either the first or the last command line parameter should be a filename.\n\n") ;
        exit (1) ;
    } ;

    /* Get the time in case we need it later. */
    memset (&sfinfo, 0, sizeof (sfinfo)) ;
    if ((file = sf_open (filename, SFM_READ, &sfinfo)) == NULL)
    {   printf ("Error : Open of file '%s' failed : %s\n\n", filename, sf_strerror (file)) ;
        exit (1) ;
    } ;

    memset (&binfo, 0, sizeof (binfo)) ;
    if (sf_command (file, SFC_GET_BROADCAST_INFO, &binfo, sizeof (binfo)) == 0)
        memset (&binfo, 0, sizeof (binfo)) ;

    process_args (file, &binfo, argc - 2, argv + start) ;

    sf_close (file) ;
    return 0 ;
} /* main */
开发者ID:Grunji,项目名称:audacity,代码行数:45,代码来源:sndfile-metadata-get.c


示例6: string_in_log_buffer

int
string_in_log_buffer (SNDFILE *file, const char *s)
{	static char	buffer [LOG_BUFFER_SIZE] ;
	int			count ;

	memset (buffer, 0, LOG_BUFFER_SIZE) ;

	/* Get the log buffer data. */
	count = sf_command	(file, SFC_GET_LOG_INFO, buffer, LOG_BUFFER_SIZE) ;

	if (LOG_BUFFER_SIZE - count < 2)
	{	printf ("Possible long log buffer.\n") ;
		exit (1) ;
		}

	/* Look for string */
	return strstr (buffer, s) ? SF_TRUE : SF_FALSE ;
} /* string_in_log_buffer */
开发者ID:ruthmagnus,项目名称:audacity,代码行数:18,代码来源:utils.c


示例7: sf_ctrl

// Write SF control
void sf_ctrl(u8 data)
{
    if (data & SPIFL_MASK_EN)
    // SF enabled
    {
        if (sf_state == SF_ST_INACT)
        // enable SFI
            sfi_enable();

        else
        // execute command
            sf_command(data);
    }

    else
        // disable SFI
        sfi_disable();   // enable JTAG
}
开发者ID:tslabs,项目名称:zx-evo,代码行数:19,代码来源:spiflash.c


示例8: startread

/*
 * Open file in sndfile.
 */
static int startread(sox_format_t * ft)
{
  priv_t * sf = (priv_t *)ft->priv;
  unsigned bits_per_sample;
  sox_encoding_t encoding;
  sox_rate_t rate;

  start(ft);

  sf->sf_file = sf_open_fd(fileno(ft->fp), SFM_READ, sf->sf_info, 1);
  ft->fp = NULL; /* Transfer ownership of fp to LSF */
  drain_log_buffer(ft);

  if (sf->sf_file == NULL) {
    memset(ft->sox_errstr, 0, sizeof(ft->sox_errstr));
    strncpy(ft->sox_errstr, sf_strerror(sf->sf_file), sizeof(ft->sox_errstr)-1);
    free(sf->sf_file);
    return SOX_EOF;
  }

  if (!(encoding = sox_enc(sf->sf_info->format, &bits_per_sample))) {
    lsx_fail_errno(ft, SOX_EFMT, "unsupported sndfile encoding %#x", sf->sf_info->format);
    return SOX_EOF;
  }

  /* Don't believe LSF's rate for raw files */
  if ((sf->sf_info->format & SF_FORMAT_TYPEMASK) == SF_FORMAT_RAW && !ft->signal.rate) {
    lsx_warn("'%s': sample rate not specified; trying 8kHz", ft->filename);
    rate = 8000;
  }
  else rate = sf->sf_info->samplerate;

#if 0
  if ((sf->sf_info->format & SF_FORMAT_SUBMASK) == SF_FORMAT_FLOAT)
    sf_command(sf->sf_file, SFC_SET_SCALE_FLOAT_INT_READ, NULL, SF_TRUE);
#endif

#if 0 /* FIXME */
    sox_append_comments(&ft->oob.comments, buf);
#endif

  return check_read_params(ft, (unsigned)sf->sf_info->channels, rate,
      encoding, bits_per_sample, (off_t)(sf->sf_info->frames * sf->sf_info->channels));
}
开发者ID:Emisense,项目名称:eTracks,代码行数:47,代码来源:sndfile.c


示例9: main

int     main (int argc, char *argv[])
{	static	char	strbuffer [BUFFER_LEN] ;
	unsigned int	linecount ;
	char 		*progname, *infilename ;
	SNDFILE	 	*infile ;
	SF_INFO	 	sfinfo ;
	int			k, start, readcount ;

	progname = strrchr (argv [0], '/') ;
	progname = progname ? progname + 1 : argv [0] ;
		
	if (argc != 2)
	{	print_usage (progname) ;
		return  1 ;
		} ;
		
	infilename = argv [1] ;
		
	if (! (infile = sf_open (infilename, SFM_READ, &sfinfo)))
	{	printf ("Error : Not able to open input file %s.\n", infilename) ;
		sf_perror (NULL) ;
		sf_command (NULL, SFC_GET_LOG_INFO, strbuffer, BUFFER_LEN) ;
		printf (strbuffer) ;
		return  1 ;
		} ;
		
	start = 0 ;
	
	linecount = 24 ;
	
	while ((readcount = sf_read_raw (infile, strbuffer, linecount)))
	{	printf ("%08X: ", start) ;
		for (k = 0 ; k < readcount ; k++)
			printf ("%02X ", strbuffer [k] & 0xFF) ;
		for (k = readcount ; k < 16 ; k++)
			printf ("   ") ;
		printf ("\n") ;
		start += readcount ;
		} ;

	sf_close (infile) ;
	
	return 0 ;
} /* main */
开发者ID:Kirushanr,项目名称:audacity,代码行数:44,代码来源:sfhexdump.c


示例10: TFileAudioStream

TReadFileAudioStream::TReadFileAudioStream(string name, long beginFrame): TFileAudioStream(name)
{
  	memset(&fInfo, 0, sizeof(fInfo));
	char utf8name[512] = {0};
	
	assert(fName.size() < 512);
	Convert2UTF8(fName.c_str(), utf8name, 512);
	fFile = sf_open(utf8name, SFM_READ, &fInfo);
	
    // Check file
    if (!fFile) {
        throw - 1;
    }

    if (sf_seek(fFile, beginFrame, SEEK_SET) < 0) {
        sf_close(fFile);
        throw - 2;
    }

    fFramesNum = long(fInfo.frames);
    fChannels = long(fInfo.channels);
    fBeginFrame = beginFrame;

	// Needed because we later on use sf_readf_short, should be removed is sf_readf_float is used instead.
    if (fInfo.format & SF_FORMAT_FLOAT) {
        int arg = SF_TRUE;
        sf_command(fFile, SFC_SET_SCALE_FLOAT_INT_READ, &arg, sizeof(arg));
    }

    if (fInfo.samplerate != TAudioGlobals::fSampleRate) {
        printf("Warning : file sample rate different from engine sample rate! lib sr = %ld file sr = %d\n", TAudioGlobals::fSampleRate, fInfo.samplerate);
    }

    // Dynamic allocation
    fMemoryBuffer = new TLocalAudioBuffer<short>(TAudioGlobals::fStreamBufferSize, fChannels);
    fCopyBuffer = new TLocalAudioBuffer<short>(TAudioGlobals::fStreamBufferSize, fChannels);
  
    // Read first buffer directly
    TBufferedAudioStream::ReadBuffer(fMemoryBuffer, TAudioGlobals::fStreamBufferSize, 0);
    TAudioBuffer<short>::Copy(fCopyBuffer, 0, fMemoryBuffer, 0, TAudioGlobals::fStreamBufferSize);

    fReady = true;
}
开发者ID:UIKit0,项目名称:libaudiostream,代码行数:43,代码来源:TReadFileAudioStream.cpp


示例11: sf_command

void QcWaveform::doLoad( SNDFILE *new_sf, const SF_INFO &new_info, sf_count_t beg, sf_count_t dur )
{
  // set up soundfile to scale data in range [-1,1] to int range
  // when reading floating point data as int
  sf_command( new_sf, SFC_SET_SCALE_FLOAT_INT_READ, NULL, SF_TRUE );

  // check beginning and duration validity

  if( beg < 0 || dur < 1 || beg + dur > new_info.frames ) {
    qcErrorMsg("Invalid beginning and/or duration.");
    sf_close( new_sf );
    return;
  }

  // cleanup previous state

  // NOTE we have to delete SoundCacheStream before closing the soundfile, as it might be still
  // loading it
  // TODO: should SoundCacheStream open the soundfile on its own?

  delete _cache;
  if( sf ) sf_close( sf );

  sf = new_sf;
  sfInfo = new_info;
  _beg = _rangeBeg = beg;
  _dur = _rangeDur = dur;
  _rangeEnd = _rangeBeg + _rangeDur;

  updateFPP();

  _cache = new SoundCacheStream();
  connect( _cache, SIGNAL(loadProgress(int)),
           this, SIGNAL(loadProgress(int)) );
  connect( _cache, SIGNAL(loadProgress(int)),
           this, SLOT(update()) );
  connect( _cache, SIGNAL(loadingDone()), this, SIGNAL(loadingDone()) );
  connect( _cache, SIGNAL(loadingDone()), this, SLOT(redraw()) );

  _cache->load( sf, sfInfo, beg, dur, kMaxFramesPerCacheUnit, kMaxRawFrames );

  redraw();
}
开发者ID:acamari,项目名称:supercollider,代码行数:43,代码来源:view.cpp


示例12: World_GetNRTBuf

bool BufWriteCmd::Stage2()
{
#ifdef NO_LIBSNDFILE
	return false;
#else
	SndBuf *buf = World_GetNRTBuf(mWorld, mBufIndex);
	int framesToEnd = buf->frames - mBufOffset;
	if (framesToEnd < 0) framesToEnd = 0;
	mFileInfo.samplerate = (int)buf->samplerate;
	mFileInfo.channels = buf->channels;

	SNDFILE* sf = sf_open(mFilename, SFM_WRITE, &mFileInfo);
	if (!sf) {
		char str[512];
		sprintf(str, "File '%s' could not be opened: %s\n", mFilename, sf_strerror(NULL));
		SendFailureWithIntValue(&mReplyAddress, "/b_write", str, mBufIndex); //SendFailure(&mReplyAddress, "/b_write", str);
		scprintf(str);
		return false;
	}

	if (mNumFrames < 0 || mNumFrames > buf->frames) mNumFrames = buf->frames;

	if (mNumFrames > framesToEnd) mNumFrames = framesToEnd;

	sf_command(sf, SFC_SET_CLIPPING, NULL, SF_TRUE); // choose clipping rather than wraparound for integer-format files

	if (mNumFrames > 0) {
		sf_writef_float(sf, buf->data + (mBufOffset * buf->channels), mNumFrames);
	}

	if(buf->sndfile)
		sf_close(buf->sndfile);

	if (mLeaveFileOpen) {
		buf->sndfile = sf;
	} else {
		sf_close(sf);
		buf->sndfile = 0;
	}

	return true;
#endif
}
开发者ID:ARTisERR0R,项目名称:supercollider,代码行数:43,代码来源:SC_SequencedCommand.cpp


示例13: libsndfile_stream_open

int
libsndfile_stream_open(const char * filename, s_stream * stream,
                       s_params * params)
{
  libsndfile_context *context;
  FILE *dummyfile;

  dummyfile = fopen(filename, "rb");
  if (!dummyfile)
    return 0;
  else
    fclose(dummyfile);

  context = (libsndfile_context *) malloc(sizeof(libsndfile_context));
  libsndfile_init_context(context);

  context->file = sf_open (filename, SFM_READ, &context->sfinfo) ;
  if (!context->file) {
    libsndfile_cleanup_context(context);
    free(context);
    return 0;
  }
  sf_command (context->file, SFC_SET_NORM_DOUBLE, NULL, SF_TRUE) ;

  s_stream_context_set(stream, (void *)context);

  /* FIXME: SF_INFO::frames is of type sf_count_t, which is a 32bit
     integer in some libsndfile version and 64bit on others (like the
     Mac OS X one), so casting context->sfinfo.frames to int is not
     totally correct - but necessary, since we do not have a 64bit
     s_params type.
     20030108 kyrah
  */
  s_params_set(s_stream_params(stream),
               "samplerate", S_INTEGER_PARAM_TYPE, context->sfinfo.samplerate,
               "frames",     S_INTEGER_PARAM_TYPE, (int) context->sfinfo.frames,
               "channels",   S_INTEGER_PARAM_TYPE, context->sfinfo.channels,
               NULL);

  return 1;
}
开发者ID:Alexpux,项目名称:simage,代码行数:41,代码来源:simage_libsndfile.c


示例14: test

/* If byfd is true, try to open the file with sf_open_fd */
int test(const char* filename, int byfd)
{
    SF_INFO     info;
    SNDFILE*    file;
    int         fid, flags, st;
    char        buffer [2048];

    st  = 0;

    flags = O_RDONLY;
#if (defined (WIN32) || defined (_WIN32))
    flags |= O_BINARY;
#endif

    info.format = 0;
    if (byfd) {
        fid = open(filename, flags);
        if (fid < 0) {
            fprintf(stderr, "%s:%s failed opening file %s\n", __FILE__, __func__, filename);
            return -1;
        }

        file = sf_open_fd(fid, SFM_READ, &info, SF_TRUE);
    } else {
        file = sf_open(filename, SFM_READ, &info);
    }

    if (file == NULL) {
        fprintf(stderr, "%s:%s failed opening file %s\n", __FILE__, __func__, filename);
        sf_command (file, SFC_GET_LOG_INFO, buffer, sizeof (buffer)) ;
        fprintf(stderr, "sndfile error is %s:\n", buffer);
        close(fid);
        exit(EXIT_FAILURE);
    } else {
        fprintf(stderr, "%s:%s file %s has %d frames \n", __FILE__, __func__, filename, info.frames);
    }

    sf_close(file);

    return st;
}
开发者ID:EQ4,项目名称:audiolab,代码行数:42,代码来源:winfdopen.c


示例15: AU_WaveGenVisual

/* Generate a reduced waveform for visualization purposes. */
int
AU_WaveGenVisual(AU_Wave *w, int reduce)
{
	int i, j, ch;
	float *pIn, *pViz;

	if (reduce <= 0) {
		AG_SetError("Reduction factor <= 0");
		return (-1);
	}
	if (w->vizFrames != NULL) {
		Free(w->vizFrames);
		w->nVizFrames = 0;
	}

	sf_command(w->file, SFC_CALC_SIGNAL_MAX, &w->peak, sizeof(w->peak));
	w->nVizFrames = w->nFrames/reduce;
	if ((w->vizFrames = AG_TryMalloc(w->nVizFrames*sizeof(float))) == NULL) {
		w->nVizFrames = 0;
		return (-1);
	}

	pViz = &w->vizFrames[0];
	for (i = 0; i < w->nVizFrames; i++) {
		for (ch = 0; ch < w->ch; ch++)
			*pViz++ = 0.0;
	}
	pIn = &w->frames[0];
	pViz = &w->vizFrames[0];
	for (i = 0; i < w->nVizFrames; i++) {
		for (j = 0; j < reduce; j++) {
			for (ch = 0; ch < w->ch; ch++) {
				pViz[ch] += MAX(w->vizFrames[i],
				    fabs((*pIn++)/w->peak));
			}
		}
		for (ch = 0; ch < w->ch; ch++)
			*pViz++ /= reduce;
	}
	return (0);
}
开发者ID:LiberatorUSA,项目名称:GUCEF,代码行数:42,代码来源:au_wave.c


示例16: drain_log_buffer

/*
 * Drain LSF's wonderful log buffer
 */
static void drain_log_buffer(sox_format_t * ft)
{
  priv_t * sf = (priv_t *)ft->priv;
  sf_command(sf->sf_file, SFC_GET_LOG_INFO, sf->log_buffer, LOG_MAX);
  while (*sf->log_buffer_ptr) {
    static char const warning_prefix[] = "*** Warning : ";
    char const * end = strchr(sf->log_buffer_ptr, '\n');
    if (!end)
      end = strchr(sf->log_buffer_ptr, '\0');
    if (!strncmp(sf->log_buffer_ptr, warning_prefix, strlen(warning_prefix))) {
      sf->log_buffer_ptr += strlen(warning_prefix);
      lsx_warn("`%s': %.*s",
          ft->filename, (int)(end - sf->log_buffer_ptr), sf->log_buffer_ptr);
    } else
      lsx_debug("`%s': %.*s",
          ft->filename, (int)(end - sf->log_buffer_ptr), sf->log_buffer_ptr);
    sf->log_buffer_ptr = end;
    if (*sf->log_buffer_ptr == '\n')
      ++sf->log_buffer_ptr;
  }
}
开发者ID:ProductosDavid,项目名称:PapelyLapiz,代码行数:24,代码来源:sndfile.c


示例17: print_usage

static void
print_usage (char *progname)
{	SF_FORMAT_INFO	info ;

	int k ;

	printf ("\nUsage : %s [encoding] <input file> <output file>\n", progname) ;
	puts ("\n"
		"    where [encoding] may be one of the following:\n\n"
		"        -pcms8     : force the output to signed 8 bit pcm\n"
		"        -pcmu8     : force the output to unsigned 8 bit pcm\n"
		"        -pcm16     : force the output to 16 bit pcm\n"
		"        -pcm24     : force the output to 24 bit pcm\n"
		"        -pcm32     : force the output to 32 bit pcm\n"
		"        -float32   : force the output to 32 bit floating point"
		) ;
	puts (
		"        -ulaw      : force the output ULAW\n"
		"        -alaw      : force the output ALAW\n"
		"        -ima-adpcm : force the output to IMA ADPCM (WAV only)\n"
		"        -ms-adpcm  : force the output to MS ADPCM (WAV only)\n"
		"        -gsm610    : force the GSM6.10 (WAV only)\n"
		"        -dwvw12    : force the output to 12 bit DWVW (AIFF only)\n"
		"        -dwvw16    : force the output to 16 bit DWVW (AIFF only)\n"
		"        -dwvw24    : force the output to 24 bit DWVW (AIFF only)\n"
		) ;

	puts (
		"    The format of the output file is determined by the file extension of the\n"
		"    output file name. The following extensions are currently understood:\n"
		) ;

	for (k = 0 ; k < (int) (sizeof (format_map) / sizeof (format_map [0])) ; k++)
	{	info.format = format_map [k].format ;
		sf_command (NULL, SFC_GET_FORMAT_INFO, &info, sizeof (info)) ;
		printf ("        %-10s : %s\n", format_map [k].ext, info.name) ;
		} ;

	puts ("") ;
} /* print_usage */
开发者ID:AaronFae,项目名称:VimProject,代码行数:40,代码来源:sndfile-convert.c


示例18: sf_open

static
float *readaudio_snd(const char *filename, long *sr, const float nbsecs, unsigned int *buflen) {

    SF_INFO sf_info;
    sf_info.format=0;
    SNDFILE *sndfile = sf_open(filename, SFM_READ, &sf_info);
    if (sndfile == NULL) {
        return NULL;
    }

    /* normalize */
    sf_command(sndfile, SFC_SET_NORM_FLOAT, NULL, SF_TRUE);

    *sr = (long)sf_info.samplerate;

    //allocate input buffer for signal
    unsigned int src_frames = (nbsecs <= 0) ? sf_info.frames : (nbsecs*sf_info.samplerate);
    src_frames = (sf_info.frames < src_frames) ? sf_info.frames : src_frames;
    float *inbuf = (float*)malloc(src_frames*sf_info.channels*sizeof(float));

    /*read frames */
    sf_count_t cnt_frames = sf_readf_float(sndfile, inbuf, src_frames);

    float *buf = (float*)malloc(cnt_frames*sizeof(float));

    //average across all channels
    int  i,j,indx=0;
    for (i=0; i<cnt_frames*sf_info.channels; i+=sf_info.channels) {
        buf[indx] = 0;
        for (j=0; j<sf_info.channels; j++) {
            buf[indx] += inbuf[i+j];
        }
        buf[indx++] /= sf_info.channels;
    }
    free(inbuf);

    *buflen = indx;
    return buf;
}
开发者ID:HeeJaeYo,项目名称:pHash,代码行数:39,代码来源:audiophash.cpp


示例19: setup_disk_thread

static void
setup_disk_thread (jack_thread_info_t *info)
{
	SF_INFO sf_info;
	int short_mask;

	sf_info.samplerate = info->sample_rate;
	sf_info.channels = info->channels;

	switch (info->bitdepth) {
		case 8: short_mask = SF_FORMAT_PCM_U8;
		  	break;
		case 16: short_mask = SF_FORMAT_PCM_16;
			 break;
		case 24: short_mask = SF_FORMAT_PCM_24;
			 break;
		case 32: short_mask = SF_FORMAT_PCM_32;
			 break;
		default: short_mask = SF_FORMAT_PCM_16;
			 break;
	}
	sf_info.format = SF_FORMAT_WAV|short_mask;

	if ((info->sf = sf_open (info->path, SFM_WRITE, &sf_info)) == NULL) {
		char errstr[256];
		sf_error_str (0, errstr, sizeof (errstr) - 1);
		fprintf (stderr, "cannot open sndfile \"%s\" for output (%s)\n", info->path, errstr);
		jack_client_close (info->client);
		exit (1);
	}

	sf_command (info->sf, SFC_SET_CLIPPING, NULL, SF_TRUE);

	info->duration *= sf_info.samplerate;
	info->can_capture = 0;

	pthread_create (&info->thread_id, NULL, disk_thread, info);
}
开发者ID:alex-berman,项目名称:tforms,代码行数:38,代码来源:jack_capture.c


示例20: sf_command

QStringList Version::dependencyVersions() {
    char sndfile_version[128];
    sf_command(nullptr, SFC_GET_LIB_VERSION, sndfile_version, sizeof(sndfile_version));
    // Null-terminate just in case.
    sndfile_version[sizeof(sndfile_version) - 1] = '\0';
    // WARNING: may be inaccurate since some come from compile-time header
    // definitions instead of the actual dynamically loaded library).
    QStringList result;
    result
            // Should be accurate.
            << QString("Qt: %1").arg(qVersion())
#ifdef __BROADCAST__
            // Should be accurate.
            << QString("libshout: %1").arg(shout_version(NULL, NULL, NULL))
#endif
            << QString("PortAudio: %1 %2").arg(Pa_GetVersion()).arg(Pa_GetVersionText())
            // The version of the RubberBand headers Mixxx was compiled with.
            << QString("RubberBand: %1").arg(RUBBERBAND_VERSION)
            // The version of the SoundTouch headers Mixxx was compiled with.
            << QString("SoundTouch: %1").arg(SOUNDTOUCH_VERSION)
            // The version of the TagLib headers Mixxx was compiled with.
            << QString("TagLib: %1.%2.%3").arg(QString::number(TAGLIB_MAJOR_VERSION),
                                               QString::number(TAGLIB_MINOR_VERSION),
                                               QString::number(TAGLIB_PATCH_VERSION))
            // The version of the ChromaPrint headers Mixxx was compiled with.
            << QString("ChromaPrint: %1.%2.%3").arg(QString::number(CHROMAPRINT_VERSION_MAJOR),
                                                    QString::number(CHROMAPRINT_VERSION_MINOR),
                                                    QString::number(CHROMAPRINT_VERSION_PATCH))
            // Should be accurate.
            << QString("Vorbis: %1").arg(vorbis_version_string())
            // Should be accurate.
            << QString("libsndfile: %1").arg(sndfile_version)
            // The version of the FLAC headers Mixxx was compiled with.
            << QString("FLAC: %1").arg(FLAC__VERSION_STRING)
            << QString("libmp3lame: %1").arg(get_lame_version());

    return result;
}
开发者ID:midzer,项目名称:mixxx,代码行数:38,代码来源:version.cpp



注:本文中的sf_command函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ sf_crmul函数代码示例发布时间:2022-05-30
下一篇:
C++ sf_cmul函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap