本文整理汇总了C++中fmod::System::getRecordPosition方法的典型用法代码示例。如果您正苦于以下问题:C++ System::getRecordPosition方法的具体用法?C++ System::getRecordPosition怎么用?C++ System::getRecordPosition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类fmod::System
的用法示例。
在下文中一共展示了System::getRecordPosition方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
//.........这里部分代码省略.........
if (kbhit())
{
key = getch();
switch (key)
{
case 'r' :
case 'R' :
{
result = system->recordStart(recorddriver, sound, looping);
ERRCHECK(result);
break;
}
case 'p' :
case 'P' :
{
if (looping)
{
sound->setMode(FMOD_LOOP_NORMAL);
}
else
{
sound->setMode(FMOD_LOOP_OFF);
}
ERRCHECK(result);
result = system->playSound(FMOD_CHANNEL_REUSE, sound, false, &channel);
ERRCHECK(result);
break;
}
case 'l' :
case 'L' :
{
looping = !looping;
break;
}
case 's' :
case 'S' :
{
result = system->recordStop(recorddriver);
if (channel)
{
channel->stop();
channel = 0;
}
break;
}
case 'w' :
case 'W' :
{
printf("Writing to record.wav ... \r");
SaveToWav(sound);
Sleep(500);
break;
}
}
}
sound->getLength(&length, FMOD_TIMEUNIT_PCM);
ERRCHECK(result);
system->isRecording(recorddriver, &recording);
ERRCHECK(result);
system->getRecordPosition(recorddriver, &recordpos);
ERRCHECK(result);
if (channel)
{
channel->isPlaying(&playing);
ERRCHECK(result);
channel->getPosition(&playpos, FMOD_TIMEUNIT_PCM);
ERRCHECK(result);
}
printf("State: %-19s. Record pos = %6d : Play pos = %6d : Loop %-3s\r", recording ? playing ? "Recording / playing" : "Recording" : playing ? "Playing" : "Idle", recordpos, playpos, looping ? "On" : "Off");
fflush(stdout);
system->update();
fflush(stdout);
Sleep(10);
} while (key != 27);
printf("\n");
/*
Shut down
*/
result = sound->release();
ERRCHECK(result);
result = system->release();
ERRCHECK(result);
return 0;
}
示例2: FMOD_Main
//.........这里部分代码省略.........
unsigned int soundLength = 0;
result = sound->getLength(&soundLength, FMOD_TIMEUNIT_PCM);
ERRCHECK(result);
/*
Main loop
*/
do
{
Common_Update();
/*
Add a DSP effect -- just for fun
*/
if (Common_BtnPress(BTN_ACTION1))
{
FMOD_REVERB_PROPERTIES propOn = FMOD_PRESET_CONCERTHALL;
FMOD_REVERB_PROPERTIES propOff = FMOD_PRESET_OFF;
dspEnabled = !dspEnabled;
result = system->setReverbProperties(0, dspEnabled ? &propOn : &propOff);
ERRCHECK(result);
}
result = system->update();
ERRCHECK(result);
/*
Determine how much has been recorded since we last checked
*/
unsigned int recordPos = 0;
result = system->getRecordPosition(DEVICE_INDEX, &recordPos);
if (result != FMOD_ERR_RECORD_DISCONNECTED)
{
ERRCHECK(result);
}
static unsigned int lastRecordPos = 0;
unsigned int recordDelta = (recordPos >= lastRecordPos) ? (recordPos - lastRecordPos) : (recordPos + soundLength - lastRecordPos);
lastRecordPos = recordPos;
samplesRecorded += recordDelta;
static unsigned int minRecordDelta = (unsigned int)-1;
if (recordDelta && (recordDelta < minRecordDelta))
{
minRecordDelta = recordDelta; /* Smallest driver granularity seen so far */
adjustedLatency = (recordDelta <= desiredLatency) ? desiredLatency : recordDelta; /* Adjust our latency if driver granularity is high */
}
/*
Delay playback until our desired latency is reached.
*/
if (!channel && samplesRecorded >= adjustedLatency)
{
result = system->playSound(sound, 0, false, &channel);
ERRCHECK(result);
}
if (channel)
{
/*
Stop playback if recording stops.
*/
bool isRecording = false;
示例3: main
//.........这里部分代码省略.........
ERRCHECK(result);
printf("Press 'Esc' to quit\n");
printf("\n");
fp = fopen("record.wav", "wb");
if (!fp)
{
printf("ERROR : could not open record.wav for writing.\n");
return 1;
}
/*
Write out the wav header. As we don't know the length yet it will be 0.
*/
WriteWavHeader(fp, sound, datalength);
result = sound->getLength(&soundlength, FMOD_TIMEUNIT_PCM);
ERRCHECK(result);
/*
Main loop.
*/
do
{
static unsigned int lastrecordpos = 0;
unsigned int recordpos = 0;
if (_kbhit())
{
key = _getch();
}
system->getRecordPosition(recorddriver, &recordpos);
ERRCHECK(result);
if (recordpos != lastrecordpos)
{
void *ptr1, *ptr2;
int blocklength;
unsigned int len1, len2;
blocklength = (int)recordpos - (int)lastrecordpos;
if (blocklength < 0)
{
blocklength += soundlength;
}
/*
Lock the sound to get access to the raw data.
*/
sound->lock(lastrecordpos * exinfo.numchannels * 2, blocklength * exinfo.numchannels * 2, &ptr1, &ptr2, &len1, &len2); /* * exinfo.numchannels * 2 = stereo 16bit. 1 sample = 4 bytes. */
/*
Write it to disk.
*/
if (ptr1 && len1)
{
datalength += fwrite(ptr1, 1, len1, fp);
}
if (ptr2 && len2)
{
datalength += fwrite(ptr2, 1, len2, fp);
}
/*
示例4: main
//.........这里部分代码省略.........
ERRCHECK(result);
printf("Press 'Esc' to quit\n");
printf("\n");
fp = fopen("record.wav", "wb");
if (!fp)
{
printf("ERROR : could not open record.wav for writing.\n");
return 1;
}
/*
Write out the wav header. As we don't know the length yet it will be 0.
*/
WriteWavHeader(fp, sound, datalength);
result = sound->getLength(&soundlength, FMOD_TIMEUNIT_PCM);
ERRCHECK(result);
/*
Main loop.
*/
do
{
static unsigned int lastrecordpos = 0;
unsigned int recordpos = 0;
if (kbhit())
{
key = getch();
}
system->getRecordPosition(recorddriver, &recordpos);
ERRCHECK(result);
if (recordpos != lastrecordpos)
{
void *ptr1, *ptr2;
int blocklength;
unsigned int len1, len2;
blocklength = (int)recordpos - (int)lastrecordpos;
if (blocklength < 0)
{
blocklength += soundlength;
}
/*
Lock the sound to get access to the raw data.
*/
if(iscoreaudio)
{
sound->lock(lastrecordpos * 8, blocklength * 8, &ptr1, &ptr2, &len1, &len2); /* *8 = stereo 32bit. 1 sample = 8 bytes. */
}
else
{
sound->lock(lastrecordpos * 4, blocklength * 4, &ptr1, &ptr2, &len1, &len2); /* *4 = stereo 16bit. 1 sample = 4 bytes. */
}
/*
Write it to disk.
*/
if (ptr1 && len1)
{
#ifdef __BIG_ENDIAN__