本文整理汇总了C++中fmod::System::recordStart方法的典型用法代码示例。如果您正苦于以下问题:C++ System::recordStart方法的具体用法?C++ System::recordStart怎么用?C++ System::recordStart使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类fmod::System
的用法示例。
在下文中一共展示了System::recordStart方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
//.........这里部分代码省略.........
printf("Recording example. Copyright (c) Firelight Technologies 2004-2011.\n");
printf("===================================================================\n");
printf("\n");
printf("Press 'r' to record a 5 second segment of audio and write it to a wav file.\n");
printf("Press 'p' to play the 5 second segment of audio.\n");
printf("Press 'l' to turn looping on/off.\n");
printf("Press 's' to stop recording and playback.\n");
printf("Press 'w' to save the 5 second segment to a wav file.\n");
printf("Press 'Esc' to quit\n");
printf("\n");
/*
Main loop.
*/
do
{
static FMOD::Channel *channel = 0;
static bool looping = false;
bool recording = false;
bool playing = false;
unsigned int recordpos = 0;
unsigned int playpos = 0;
unsigned int length;
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)
{
示例2: main
//.........这里部分代码省略.........
result = system->init(32, FMOD_INIT_NORMAL, 0);
ERRCHECK(result);
system->getSoftwareFormat(&outputfreq, 0, 0, 0, 0, 0);
ERRCHECK(result);
/*
Create a sound to record to.
*/
memset(&exinfo, 0, sizeof(FMOD_CREATESOUNDEXINFO));
exinfo.cbsize = sizeof(FMOD_CREATESOUNDEXINFO);
exinfo.numchannels = 1;
exinfo.format = FMOD_SOUND_FORMAT_PCM16;
exinfo.defaultfrequency = OUTPUTRATE;
exinfo.length = exinfo.defaultfrequency * sizeof(short) * exinfo.numchannels * 5;
result = system->createSound(0, FMOD_2D | FMOD_SOFTWARE | FMOD_LOOP_NORMAL | FMOD_OPENUSER, &exinfo, &sound);
ERRCHECK(result);
/*
Start the interface
*/
printf("=========================================================================\n");
printf("Pitch detection example. Copyright (c) Firelight Technologies 2004-2014.\n");
printf("=========================================================================\n");
printf("\n");
printf("Record something through the selected recording device and FMOD will\n");
printf("Determine the pitch. Sustain the tone for at least a second to get an\n");
printf("accurate reading.\n");
printf("Press 'Esc' to quit\n");
printf("\n");
result = system->recordStart(recorddriver, sound, true);
ERRCHECK(result);
Sleep(200); /* Give it some time to record something */
result = system->playSound(FMOD_CHANNEL_REUSE, sound, false, &channel);
ERRCHECK(result);
/* Dont hear what is being recorded otherwise it will feedback. Spectrum analysis is done before volume scaling in the DSP chain */
result = channel->setVolume(0);
ERRCHECK(result);
bin = 0;
/*
Main loop.
*/
do
{
static float spectrum[SPECTRUMSIZE];
float dominanthz = 0;
float max;
int dominantnote = 0;
float binsize = BINSIZE;
if (kbhit())
{
key = getch();
}
result = channel->getSpectrum(spectrum, SPECTRUMSIZE, 0, FMOD_DSP_FFT_WINDOW_TRIANGLE);
ERRCHECK(result);
示例3: FMOD_Main
int FMOD_Main()
{
FMOD::Channel *channel = NULL;
unsigned int samplesRecorded = 0;
unsigned int samplesPlayed = 0;
bool dspEnabled = false;
void *extraDriverData = NULL;
Common_Init(&extraDriverData);
/*
Create a System object and initialize.
*/
FMOD::System *system = NULL;
FMOD_RESULT result = FMOD::System_Create(&system);
ERRCHECK(result);
unsigned int version = 0;
result = system->getVersion(&version);
ERRCHECK(result);
if (version < FMOD_VERSION)
{
Common_Fatal("FMOD lib version %08x doesn't match header version %08x", version, FMOD_VERSION);
}
result = system->init(100, FMOD_INIT_NORMAL, extraDriverData);
ERRCHECK(result);
int numDrivers = 0;
result = system->getRecordNumDrivers(NULL, &numDrivers);
ERRCHECK(result);
if (numDrivers == 0)
{
Common_Fatal("No recording devices found/plugged in! Aborting.");
}
/*
Determine latency in samples.
*/
int nativeRate = 0;
int nativeChannels = 0;
result = system->getRecordDriverInfo(DEVICE_INDEX, NULL, 0, NULL, &nativeRate, NULL, &nativeChannels, NULL);
ERRCHECK(result);
unsigned int driftThreshold = (nativeRate * DRIFT_MS) / 1000; /* The point where we start compensating for drift */
unsigned int desiredLatency = (nativeRate * LATENCY_MS) / 1000; /* User specified latency */
unsigned int adjustedLatency = desiredLatency; /* User specified latency adjusted for driver update granularity */
int actualLatency = desiredLatency; /* Latency measured once playback begins (smoothened for jitter) */
/*
Create user sound to record into, then start recording.
*/
FMOD_CREATESOUNDEXINFO exinfo = {0};
exinfo.cbsize = sizeof(FMOD_CREATESOUNDEXINFO);
exinfo.numchannels = nativeChannels;
exinfo.format = FMOD_SOUND_FORMAT_PCM16;
exinfo.defaultfrequency = nativeRate;
exinfo.length = nativeRate * sizeof(short) * nativeChannels; /* 1 second buffer, size here doesn't change latency */
FMOD::Sound *sound = NULL;
result = system->createSound(0, FMOD_LOOP_NORMAL | FMOD_OPENUSER, &exinfo, &sound);
ERRCHECK(result);
result = system->recordStart(DEVICE_INDEX, sound, true);
ERRCHECK(result);
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;
//.........这里部分代码省略.........
示例4: main
//.........这里部分代码省略.........
key = _getch();
if (key == 27)
{
return 0;
}
recorddriver = key - '1';
} while (recorddriver < 0 || recorddriver >= numdrivers);
printf("\n");
result = system->init(32, FMOD_INIT_NORMAL, 0);
ERRCHECK(result);
memset(&exinfo, 0, sizeof(FMOD_CREATESOUNDEXINFO));
exinfo.cbsize = sizeof(FMOD_CREATESOUNDEXINFO);
exinfo.numchannels = 1;
exinfo.format = FMOD_SOUND_FORMAT_PCM16;
exinfo.defaultfrequency = 44100;
exinfo.length = exinfo.defaultfrequency * sizeof(short) * exinfo.numchannels * 2;
result = system->createSound(0, FMOD_2D | FMOD_SOFTWARE | FMOD_OPENUSER, &exinfo, &sound);
ERRCHECK(result);
printf("========================================================================\n");
printf("Record to disk example. Copyright (c) Firelight Technologies 2004-2014.\n");
printf("========================================================================\n");
printf("\n");
printf("Press a key to start recording to record.wav\n");
printf("\n");
_getch();
result = system->recordStart(recorddriver, sound, true);
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();
}
示例5: main
int main(int argc, char *argv[])
{
FMOD::System *system = 0;
FMOD::Sound *sound = 0;
FMOD_RESULT result;
FMOD_CREATESOUNDEXINFO exinfo;
int key, recorddriver, numdrivers, count;
unsigned int version;
FILE *fp;
unsigned int datalength = 0, soundlength;
bool iscoreaudio = false;
/*
Create a System object and initialize.
*/
result = FMOD::System_Create(&system);
ERRCHECK(result);
result = system->getVersion(&version);
ERRCHECK(result);
if (version < FMOD_VERSION)
{
printf("Error! You are using an old version of FMOD %08x. This program requires %08x\n", version, FMOD_VERSION);
return 0;
}
result = system->setOutput(FMOD_OUTPUTTYPE_COREAUDIO);
ERRCHECK(result);
/*
Enumerate record devices
*/
result = system->getRecordNumDrivers(&numdrivers);
ERRCHECK(result);
printf("---------------------------------------------------------\n");
printf("Choose a RECORD driver\n");
printf("---------------------------------------------------------\n");
for (count=0; count < numdrivers; count++)
{
char name[256];
result = system->getRecordDriverInfo(count, name, 256, 0);
ERRCHECK(result);
printf("%d : %s\n", count + 1, name);
}
printf("---------------------------------------------------------\n");
printf("Press a corresponding number or ESC to quit\n");
recorddriver = 0;
do
{
key = getch();
if (key == 27)
{
return 0;
}
recorddriver = key - '1';
} while (recorddriver < 0 || recorddriver >= numdrivers);
printf("\n");
result = system->init(32, FMOD_INIT_NORMAL, 0);
ERRCHECK(result);
memset(&exinfo, 0, sizeof(FMOD_CREATESOUNDEXINFO));
exinfo.cbsize = sizeof(FMOD_CREATESOUNDEXINFO);
exinfo.numchannels = 2;
exinfo.defaultfrequency = 44100;
if (iscoreaudio)
{
exinfo.format = FMOD_SOUND_FORMAT_PCMFLOAT;
exinfo.length = exinfo.defaultfrequency * sizeof(float) * exinfo.numchannels * 2;
}
else
{
exinfo.format = FMOD_SOUND_FORMAT_PCM16;
exinfo.length = exinfo.defaultfrequency * sizeof(short) * exinfo.numchannels * 2;
}
result = system->createSound(0, FMOD_2D | FMOD_SOFTWARE | FMOD_OPENUSER, &exinfo, &sound);
ERRCHECK(result);
printf("========================================================================\n");
printf("Record to disk example. Copyright (c) Firelight Technologies 2004-2014.\n");
printf("========================================================================\n");
printf("\n");
printf("Press a key to start recording to record.wav\n");
printf("\n");
getch();
result = system->recordStart(recorddriver, sound, true);
ERRCHECK(result);
//.........这里部分代码省略.........
示例6: DetectPitch
//.........这里部分代码省略.........
result = system->setSoftwareFormat(OUTPUT_RATE, FMOD_SOUND_FORMAT_PCM16, 1, 0, FMOD_DSP_RESAMPLER_LINEAR);
ERRCHECK(result);
result = system->init(32, FMOD_INIT_NORMAL, 0);
ERRCHECK(result);
/*
Create a sound to record to.
*/
memset(&exinfo, 0, sizeof(FMOD_CREATESOUNDEXINFO));
exinfo.cbsize = sizeof(FMOD_CREATESOUNDEXINFO);
exinfo.numchannels = 1;
exinfo.format = FMOD_SOUND_FORMAT_PCM16;
exinfo.defaultfrequency = OUTPUT_RATE;
exinfo.length = exinfo.defaultfrequency * sizeof(short) * exinfo.numchannels * 5;
result = system->createSound(0, FMOD_2D | FMOD_SOFTWARE | FMOD_LOOP_NORMAL | FMOD_OPENUSER, &exinfo, &sound);
ERRCHECK(result);
/*
Start the interface
*/
printf("=========================================================================\n");
printf("Pitch detection example. Copyright (c) Firelight Technologies 2004-2011.\n");
printf("=========================================================================\n");
printf("\n");
printf("Record something through the selected recording device and FMOD will\n");
printf("Determine the pitch. Sustain the tone for at least a second to get an\n");
printf("accurate reading.\n");
printf("Press 'Esc' to quit\n");
printf("\n");
result = system->recordStart(recorddriver, sound, true);
ERRCHECK(result);
Sleep(100); /* Give it some time to record something */
result = system->playSound(FMOD_CHANNEL_REUSE, sound, false, &channel);
ERRCHECK(result);
/* Dont hear what is being recorded otherwise it will feedback. Spectrum analysis is done before volume scaling in the DSP chain */
result = channel->setVolume(0);
ERRCHECK(result);
bin = 0;
/*
Main loop.
*/
do
{
static float spectrum[SPECTRUM_SIZE];
float dominantHz = 0;
float max;
int dominantNote = 0;
float binSize = BIN_SIZE;
bool hasUpdated = false;
char windowTitle[sizeof("Pitch Detector: ---")] = "Pitch Detector: ---";
int noteIndex;
double noteDeviation;
if (_kbhit())
{
key = _getch();
}