当前位置: 首页>>代码示例>>C++>>正文


C++ StkFrames::resize方法代码示例

本文整理汇总了C++中StkFrames::resize方法的典型用法代码示例。如果您正苦于以下问题:C++ StkFrames::resize方法的具体用法?C++ StkFrames::resize怎么用?C++ StkFrames::resize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在StkFrames的用法示例。


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

示例1: printf

Marionette::Marionette(int outdevice, float samplerate)
{
  //std::cout << "initializing Marionette C++ object" << std::endl;
  dac = new RtAudio;
    
  int output_device_id    = outdevice;  
  int num_out_channels = dac->getDeviceInfo(output_device_id).outputChannels;

  parameters.deviceId = output_device_id;
  parameters.nChannels = num_out_channels;
  printf("Device id: %d , channels %d\n", output_device_id, num_out_channels);
  // Resize the StkFrames object appropriately.
  frames.resize( RT_BUFFER_SIZE, num_out_channels );
  // default sample rate
  Stk::setSampleRate( samplerate );
  // create the global outs
  out = new Bus(num_out_channels);
  // create the global ins
  in = new Bus(0);
}
开发者ID:dmichael,项目名称:marionette,代码行数:20,代码来源:Marionette.cpp

示例2: main

int main(int argc, char *argv[])
{
  // Minimal command-line checking.
  if ( argc < 3 || argc > 4 ) usage();

  // Set the global sample rate before creating class instances.
  Stk::setSampleRate( (StkFloat) atof( argv[2] ) );

  // Initialize our WvIn and RtAudio pointers.
  RtAudio dac;
  FileWvIn input;
  FileLoop inputLoop;

  // Try to load the soundfile.
  try {
    input.openFile( argv[1] );
	inputLoop.openFile( argv[1] );
  }
  catch ( StkError & ) {
    exit( 1 );
  }

  // Set input read rate based on the default STK sample rate.
  double rate = 1.0;
  rate = input.getFileRate() / Stk::sampleRate();
  rate = inputLoop.getFileRate() / Stk::sampleRate();
  if ( argc == 4 ) rate *= atof( argv[3] );
  input.setRate( rate );

  input.ignoreSampleRateChange();

  // Find out how many channels we have.
  int channels = input.channelsOut();

  // Figure out how many bytes in an StkFloat and setup the RtAudio stream.
  RtAudio::StreamParameters parameters;
  parameters.deviceId = dac.getDefaultOutputDevice();
  parameters.nChannels = channels;
  RtAudioFormat format = ( sizeof(StkFloat) == 8 ) ? RTAUDIO_FLOAT64 : RTAUDIO_FLOAT32;
  unsigned int bufferFrames = RT_BUFFER_SIZE;
  try {
    dac.openStream( &parameters, NULL, format, (unsigned int)Stk::sampleRate(), &bufferFrames, &tick, (void *)&inputLoop );
  }
  catch ( RtAudioError &error ) {
    error.printMessage();
    goto cleanup;
  }

  // Install an interrupt handler function.
	(void) signal(SIGINT, finish);

  // Resize the StkFrames object appropriately.
  frames.resize( bufferFrames, channels );

  try {
    dac.startStream();
  }
  catch ( RtAudioError &error ) {
    error.printMessage();
    goto cleanup;
  }

  // Block waiting until callback signals done.
  while ( !done )
    Stk::sleep( 100 );
  
  // By returning a non-zero value in the callback above, the stream
  // is automatically stopped.  But we should still close it.
  try {
    dac.closeStream();
  }
  catch ( RtAudioError &error ) {
    error.printMessage();
  }

 cleanup:
  return 0;
}
开发者ID:johnty,项目名称:stk,代码行数:78,代码来源:play.cpp


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