本文整理汇总了C++中Tone类的典型用法代码示例。如果您正苦于以下问题:C++ Tone类的具体用法?C++ Tone怎么用?C++ Tone使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Tone类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: while
void SoundTask::task() {
while(true) {
Tone tone;
if(xQueueReceive(_tones, &tone, portMAX_DELAY) == pdTRUE) {
tone.play();
}
}
}
示例2: set
void set(std::string a, Tone b, Tone c, Tone d)
{
Tone zero;
zero.set("x", 0.00);
name = a;
tone1 = b;
tone2 = c;
tone3 = d;
tone4 = zero;
}
示例3: needsEffectRender
bool needsEffectRender(bool flashing)
{
bool rectEffective = !rect->isEmpty();
bool colorToneEffective = color->hasEffect() || tone->hasEffect() || flashing;
return (rectEffective && colorToneEffective && isOnScreen);
}
示例4: in
void rawGenerator::in(Tone a)
{
double x = 0, y = 0, z = 0;
const double increment1 = (a.getFrequency() / SAMPLE_RATE);
cout << "Creating a mix of: " << a.getFrequency() << endl;
cout << "Creating a mix of: " << increment1 << endl;
cout << "Samples: " << SAMPLES << endl;
cout << "Sample rate: " << SAMPLE_RATE << endl;
for (unsigned i = 0; i < SAMPLES; i++)
{
waveOut[i] = (sin(x * TWO_PI)) * AMPLITUDE;
x += increment1;
}
}
示例5: loop
void loop(){
buttonState = digitalRead(buttonPin);
if (buttonState == LOW){
for(i = 0; i < 7; i = i + 1){
mytone.play(songTones[i], 1000);
delay(1000);
}
}
else { //HERE I GO AGAIN RECORD MODE
mytone.stop(); //silence
for(i = 0; i < 7; i = i + 1){
int inVar = analogRead(0); //read the varible resistor for a value
// map the input to a frequency range between 200 and 2000 Hz
int note = map(inVar, 0, 1023, 220, 2000);
songTones[i] = note; //set value
mytone.play(note, 1000);//play value, duration small
// mytone.stop(); //silence
delay(1000);
}
//end tone?
}//end if/else
}//endloop
示例6: redrawBaseTex
void redrawBaseTex()
{
if (nullOrDisposed(windowskin))
return;
if (base.tex.tex == TEX::ID(0))
return;
FBO::bind(base.tex.fbo);
/* Clear texture */
glState.clearColor.pushSet(Vec4());
FBO::clear();
glState.clearColor.pop();
glState.viewport.pushSet(IntRect(0, 0, base.tex.width, base.tex.height));
glState.blend.pushSet(false);
ShaderBase *shader;
if (backOpacity < 255 || tone->hasEffect())
{
PlaneShader &planeShader = shState->shaders().plane;
planeShader.bind();
planeShader.setColor(Vec4());
planeShader.setFlash(Vec4());
planeShader.setTone(tone->norm);
planeShader.setOpacity(backOpacity.norm);
shader = &planeShader;
}
else
{
shader = &shState->shaders().simple;
shader->bind();
}
windowskin->bindTex(*shader);
TEX::setSmooth(true);
shader->setTranslation(Vec2i());
shader->applyViewportProj();
/* Draw stretched layer */
base.vert.draw(0, 1);
glState.blend.set(true);
glState.blendMode.pushSet(BlendKeepDestAlpha);
/* Draw tiled layer */
base.vert.draw(1, base.bgTileQuads);
glState.blendMode.set(BlendNormal);
/* If we used plane shader before, switch to simple */
if (shader != &shState->shaders().simple)
{
shader = &shState->shaders().simple;
shader->bind();
shader->setTranslation(Vec2i());
shader->applyViewportProj();
windowskin->bindTex(*shader);
}
base.vert.draw(1+base.bgTileQuads, base.borderQuads);
TEX::setSmooth(false);
glState.blendMode.pop();
glState.blend.pop();
glState.viewport.pop();
}
示例7: setup
void setup(void)
{
tone1.begin(13);
tone2.begin(12);
pinMode(2, INPUT);
pinMode(3, INPUT);
Serial.begin(9600);
}
示例8: audio_callback
void audio_callback(void* udata, Uint8* instream, int len)
{
Sint16* stream = (Sint16*)instream;
Sint16* p = stream;
while (len > 0) {
*p++ = int(3000 * TONE.fetch_left());
*p++ = int(3000 * TONE.fetch_right());
len -= 4;
}
TONE.sanitize();
}
示例9: playSection
void playSection(int notes[],int bassNote,int repeat,int length){ // play notes
for(int j=0;j<repeat;j++){
if(bassNote != 13){
tone2.play(bass[bassNote],(length - 1 * 300)); // TODO: calculate how long to play bass
}
for(int i=0;i<=length-1;i++){
tone1.play(notes[i]);
delay(300);
tone1.stop();
}
tone2.stop();
}
}
示例10: beep
//*********************************************************************************************************
void beep()
{
#ifdef _USE_ARDUINO_TONE
tone(SPEAKER_PIN2, NOTE_C8, 200);
#else
// beep after reset;
noiseMaker.play(NOTE_C8, 200);
#endif
}
示例11: setupSpeaker
//*********************************************************************************************************
void setupSpeaker()
{
// REM: should exploit the 2 sound levels, by driving both speaker pins;
pinMode(SPEAKER_PIN1, OUTPUT);
digitalWrite(SPEAKER_PIN1, LOW);
pinMode(SPEAKER_PIN2, OUTPUT);
#ifndef _USE_ARDUINO_TONE
noiseMaker.begin(SPEAKER_PIN2);
#endif
}
示例12: loop
void loop() {
note_raw = analogRead(NOTE_PIN);
beat_raw = analogRead(BEAT_PIN);
// note = dist2note[distance(note_raw)];
// if (beat_raw > BEAT_TH) {
// if (note != last_note) {
// last_note = note;
// tn.play(notes[note]);
// }
// } else {
// tn.stop()
// }
for (int i = 0; i < 89; i++) {
tn.play(all_notes[i]);
if (DELAY) {
delay(DELAY);
}
}
}
示例13: setup
void setup() {
Serial.begin(9600);
init_note_distances();
tn.begin(11);
}
示例14: setup
void setup() {
Serial.begin(9600);
tone.begin(12);
}
示例15: loop
void loop() {
for (int i; i < 12; i++) {
tone.play(note[i]);
delay(1000);
}
}