本文整理汇总了C++中audio_format类的典型用法代码示例。如果您正苦于以下问题:C++ audio_format类的具体用法?C++ audio_format怎么用?C++ audio_format使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了audio_format类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: audio_membuffer
audio_membuffer(audio_format aud_fmt, float seconds) : audio_data(0),
aud_info(aud_fmt),
buf_size(0),
init_size(0)
{
/* Allocs memory for audio recording the specified number of seconds */
init_size = (unsigned int)((float)aud_info.byte_rate() * seconds <= 0 ? 1 : seconds);
alloc_mem_(init_size);
}
示例2: create_buffer
// directsound_audio_stream::create_buffer()
void directsound_audio_stream::create_buffer(directsound_instance& instance, audio_format const& format) {
WAVEFORMATEX waveFormat;
waveFormat.wFormatTag = WAVE_FORMAT_PCM;
waveFormat.nChannels = format.channels();
waveFormat.nSamplesPerSec = format.frequency();
waveFormat.nAvgBytesPerSec = format.bytes_per_second();
waveFormat.nBlockAlign = static_cast<WORD>(format.bytes_per_frame());
waveFormat.wBitsPerSample = format.bits_per_sample();
waveFormat.cbSize = 0;
DSBUFFERDESC bufferDesc;
bufferDesc.dwSize = sizeof(DSBUFFERDESC);
bufferDesc.dwFlags = DSBCAPS_GLOBALFOCUS | DSBCAPS_GETCURRENTPOSITION2;
bufferDesc.dwReserved = 0;
bufferDesc.dwBufferBytes = static_cast<DWORD>( BufferSize_seconds.count() * format.bytes_per_second() );
bufferDesc.guid3DAlgorithm = DS3DALG_DEFAULT;
bufferDesc.lpwfxFormat = &waveFormat;
LPDIRECTSOUNDBUFFER ptr = nullptr;
if( FAILED(instance.ptr()->CreateSoundBuffer(&bufferDesc, &ptr, nullptr)) ) {
throw directsound_exception{};
}
ptr->SetFormat(&waveFormat);
_buffer = buffer_ptr{ ptr };
clear_entire_buffer();
_state = audio_stream_state::ready;
}
示例3: audio_membuffer
audio_membuffer( audio_format aud_fmt, unsigned int seconds )
: audio_data( 0 ), aud_info( aud_fmt ), buf_size( 0 ),
init_size( 0 )
{
//
// Allocs memory for audio recording
// the specified number of seconds.
//
init_size = aud_info.byte_rate() * seconds;
alloc_mem_( init_size );
}
示例4: samplevalue_max
unsigned int samplevalue_max( void )
{
if ( aud_info.bits() == 16 )
return (unsigned int )65535;
else if ( aud_info.bits() == 8 )
return (unsigned int)255;
else
return 0;
}
示例5: samples_received
unsigned int samples_received( void ) const
{
return ( aud_info.samples_in_bytes( bytes_received ));
}
示例6: tot_samples_buf
unsigned tot_samples_buf( void )
{
return aud_info.samples_in_bytes( mb_size );
}
示例7: nsample
unsigned int nsample ( unsigned int nsamp )
{
unsigned int svalue;
if ( aud_info.bits() == 16 )
svalue = ( unsigned int ) abs( *(( short * ) (main_buffer + aud_info.bytes_in_samples( nsamp ))));
else if ( aud_info.bits() == 8 )
svalue = (unsigned int)(( ptrdiff_t ) *(main_buffer + aud_info.bytes_in_samples( nsamp )));
else
svalue = 0;
return svalue;
}
示例8:
audio_membuffer( void )
: audio_data( 0 ), aud_info( _AUDIO_DEFAULT_FORMAT ),
buf_size( 0 ), init_size( 0 )
{
//
// Allocs memory for at least 1 or some seconds
// of recording.
//
init_size = ( unsigned int )
(( float )aud_info.byte_rate() * _AUDIO_DEFAULT_BUFSECS );
alloc_mem_( init_size );
}
示例9: total_samples
unsigned int total_samples( void ) const
{
return ( aud_info.samples_in_seconds( fseconds_total() ));
}
示例10: fseconds_recorded
//returns the float number of seconds
//that has been recorded
float fseconds_recorded( void ) const
{ return ( float )(( float ) bytes_received /
( float ) aud_info.byte_rate()); }
示例11: fseconds_total
//returns the float number of seconds
//that the buffer can record
float fseconds_total( void ) const
{ return ( float )(( float ) buf_size /
( float ) aud_info.byte_rate()); }
示例12: seconds_recorded
//returns the integer number of seconds
//that the buffer can record
unsigned int seconds_recorded( void ) const
{ return bytes_received / aud_info.byte_rate(); }
示例13: seconds_total
//returns the integer number of seconds
//that the buffer can record
unsigned int seconds_total( void ) const
{ return buf_size / aud_info.byte_rate(); }