您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ tone函数代码示例

51自学网 2021-06-03 08:55:24
  C++
这篇教程C++ tone函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中tone函数的典型用法代码示例。如果您正苦于以下问题:C++ tone函数的具体用法?C++ tone怎么用?C++ tone使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

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

示例1: update

	void update() {		btn.update();		led.update();		if (btn.isLongClicked()) {			speakerOn = !speakerOn;			if (speakerOn) {				tone(speakerPin, toneState.getValue());			} else {				noTone(speakerPin);			}		} else if (btn.isClicked()) {			rotor.setState(rotor.getState() == &toneState ? &ledState : &toneState);		}		if (toneState.hasValueChanged()) {			long newTone = toneState.getValue();			if (speakerOn) {				tone(speakerPin, newTone);			}			float tps = rotor.tps.getTPS();			Serial.print("Tone ");			Serial.print(newTone);			Serial.print(" ");			Serial.println(tps);		}		if (ledState.hasValueChanged()) {			int newLed = (int) ledState.getValue();			led.setState(newLed);			Serial.print("Led ");			Serial.println(newLed);		}	}
开发者ID:slavianp,项目名称:improc,代码行数:34,


示例2: if

void Music::cycle(unsigned long currentTime) {  _isPlaying = false;  // kill our playing if we are past our times  if (isEmptyMelody()) {    return;  } else if (_notePosition > (NOTES_COUNT - 1)) {    setMelody(MELODY_NONE);    return;  }  _isPlaying = true;  unsigned long toneElapsedTime = currentTime - _toneTimer;  if (!_firstNotePlayed) {    noTone(_speakerPin);    tone(_speakerPin, _currentNote, _currentDuration);    _toneTimer = currentTime;    _firstNotePlayed = true;  } else if (toneElapsedTime > (_currentDuration * 1.3)) {    noTone(_speakerPin);    _toneTimer = currentTime;    _notePosition++;    setCurrentNoteAndDuration(_notePosition);    if (isEndNote(_notePosition)) {      return;    }    tone(_speakerPin, _currentNote, _currentDuration);  }}
开发者ID:PotiBox,项目名称:PotiBox,代码行数:35,


示例3: loop

  void loop() {  // read the sensor:  int sensorone = digitalRead(2);  int sensortwo = digitalRead(3);  int sensorthree = digitalRead(4);  int sensorfour = digitalRead(5);  int sensorfive = digitalRead(6);  if (sensorone == HIGH){  // play the pitch:  tone(9, NOTE_A4, 20);  delay(1); // delay in between reads for stability  }  if (sensortwo == HIGH) {  // play the pitch:  tone(9, NOTE_G4, 20);  delay(1);   }    if (sensorthree == HIGH) {  tone(9, NOTE_E4, 20);  delay(1);  }    if (sensorfour == HIGH) {  tone(9, NOTE_D4, 20);  delay(1);  }   if (sensorfive == HIGH) {   tone(9, NOTE_C4, 20);  delay(1);  } }  
开发者ID:Open-University-Sense-Library,项目名称:Write-ups,代码行数:34,


示例4: doIndicateStep

static void doIndicateStep(uint8_t step){  switch(sequence[step])  {    case INDICATE_RED:    {      tone(SPEAKER_PIN, NOTE_A4);      digitalWrite(RED_LED_PIN, HIGH);      break;    }    case INDICATE_BLUE:    {      tone(SPEAKER_PIN, NOTE_G4);      digitalWrite(BLUE_LED_PIN, HIGH);      break;    }    case INDICATE_YELLOW:    {      tone(SPEAKER_PIN, NOTE_C4);      digitalWrite(YELLOW_LED_PIN, HIGH);      break;    }    case INDICATE_GREEN:    {      tone(SPEAKER_PIN, NOTE_G5);      digitalWrite(GREEN_LED_PIN, HIGH);      break;    }  }}
开发者ID:thingsforhackers,项目名称:CopyMe,代码行数:34,


示例5: test_spkr

int test_spkr(String input){  tone(BUZZER_PIN, 600, 150);  delay(150);  tone(BUZZER_PIN, 900, 150);  return 0;};
开发者ID:lucwastiaux,项目名称:gc,代码行数:8,


示例6: tone

void buzzer::registered(){	tone(pin,4000);	delay(300);	tone(pin,2000);	delay(300);	tone(pin,4000,200);	}
开发者ID:ajinkyagorad,项目名称:Centrallised_Attendence_System,代码行数:9,


示例7: tone

IR_rangeZone_detection::IR_rangeZone_detection(){  tone(speakerPin, 2000,500);  delay(1000);  tone(speakerPin, 2000, 500);    pinMode(irRecPinLeft, INPUT);  pinMode(irLEDPinLeft, OUTPUT);   // IR LED & Receiver  pinMode(irRecPinRight, INPUT);  pinMode(irLEDPinRight, OUTPUT);}
开发者ID:zteifel,项目名称:booboo,代码行数:9,


示例8: beep

void beep() {    tone(buzzerPin, 1000);   // Play a 1kHz tone on the pin number held in    delay(125);   // Wait for 125ms.     noTone(buzzerPin);   // Stop playing the tone.    tone(buzzerPin, 2000);  // Play a 2kHz tone on the buzzer pin    delay(500);   // delay for 1000 ms (1 second)    noTone(buzzerPin);       // Stop playing the tone.}
开发者ID:TIDAL-Lab,项目名称:tern2,代码行数:9,


示例9: successLight

void AccessControl::successTone() {    successLight();        tone(_buzzerPin, NOTE_C4);    delay(250);    noTone(_buzzerPin);    tone(_buzzerPin, NOTE_A4);    delay(250);    noTone(_buzzerPin);}
开发者ID:ArthurGuy,项目名称:RFIDAccessControl,代码行数:10,


示例10: beep4

void beep4(){  	tone(sirenPin, 4125);	delay(100);	noTone(sirenPin);	delay(50);	tone(sirenPin, 4000);	delay(500);	noTone(sirenPin);}
开发者ID:dome2048,项目名称:syc,代码行数:10,


示例11: beep1

void beep1(){  	tone(sirenPin, 4000);	delay(50);	noTone(sirenPin);	delay(50);	tone(sirenPin, 4000);	delay(50);	noTone(sirenPin);}
开发者ID:dome2048,项目名称:syc,代码行数:10,


示例12: mrb_arduino_tone

mrb_value mrb_arduino_tone(mrb_state *mrb, mrb_value self){  mrb_int pin, frequency, duration;  int n = mrb_get_args(mrb, "ii|i", &pin, &frequency, &duration);  if (n == 2){    tone(pin, frequency);  }else if(n == 3){    tone(pin, frequency, duration);  }  return mrb_nil_value();}
开发者ID:hiroeorz,项目名称:mruby-arduino,代码行数:10,


示例13: beep3

void beep3(){  	tone(sirenPin, 4000);	delay(200);	noTone(sirenPin);	delay(50);	tone(sirenPin, 4650);	delay(500);	noTone(sirenPin);}
开发者ID:dome2048,项目名称:syc,代码行数:10,


示例14: packet_received

gboolean packet_received(GtkWidget *leak) {	int i;	char *buffer;	struct tcphdr *tcp_hdr;	struct udphdr *udp_hdr;	struct ip *ip_hdr;	int linkoff=14;	buffer = (u_char *)pcap_next(pcap_d,&h);	packetcount++;	ip_hdr = (struct ip *)(buffer + linkoff);		if (ip_hdr->ip_p == IPPROTO_TCP) {		tcp_hdr=(struct tcphdr*)(((char*)ip_hdr)+(4*ip_hdr->ip_hl));		switch ((tcp_hdr->th_flags)) {				case TH_ACK:						update_port(leak, ntohs(tcp_hdr->th_dport), 0, 255, 0);				if (sound_onoff) {					tone(ntohs(tcp_hdr->th_dport), 4000, 60);				}				break;			case TH_SYN:				update_port(leak, ntohs(tcp_hdr->th_dport), 255, 255, 0); if (sound_onoff) {					tone(ntohs(tcp_hdr->th_dport), 4000, 60);				}				break;			case TH_FIN:				update_port(leak, ntohs(tcp_hdr->th_dport), 255, 0, 0);				if (sound_onoff) {					tone(ntohs(tcp_hdr->th_dport), 4000, 60);				}				break;			default:				break;		}	  	} else if (ip_hdr->ip_p == IPPROTO_UDP) {		udp_hdr=(struct udphdr*)(((char*)ip_hdr)+(4*ip_hdr->ip_hl));		update_port(leak, ntohs(udp_hdr->uh_dport), 0, 0, 255);		if (sound_onoff) {			tone(ntohs(udp_hdr->uh_dport), 4000, 60);		}	}			return TRUE;}
开发者ID:s7ephen,项目名称:leak,代码行数:55,


示例15: failureLight

//Feedback Tonesvoid AccessControl::failureTone() {    failureLight();        tone(_buzzerPin, NOTE_A5);    delay(250);    noTone(_buzzerPin);    tone(_buzzerPin, NOTE_C4);    delay(250);    noTone(_buzzerPin);    }
开发者ID:ArthurGuy,项目名称:RFIDAccessControl,代码行数:12,


示例16: waitStart

void waitStart(){    tone(E5, 50);    while((getTelemeterDist(TELEMETER_FL) >= WAIT_START_DISTANCE) &&            (getTelemeterDist(TELEMETER_FR) >= WAIT_START_DISTANCE));    tone(E5, 50);    HAL_Delay(20);    tone(E5, 50);    while((getTelemeterDist(TELEMETER_FL) <= WAIT_START_DISTANCE) ||            (getTelemeterDist(TELEMETER_FR) <= WAIT_START_DISTANCE));    toneItMode(D6, 200);}
开发者ID:pacabot,项目名称:zhonx3,代码行数:12,


示例17: main

void main(void) {    /* Initialize I/O and Peripherals for application */    TRISA = 0x02;   // RA1 input, others outpot    TRISB = 0x00;   // PortB all output    PORTA = 0x00;   // PortA all low    PORTB = 0x00;   // PortB all low    // OPTION_REG    OPTION_REG = OPTION_REG_VALUE ;    // Timer 0    tmr0_value = 114;   // RA    t333ms_max = 133;    TMR0 = tmr0_value ;    // TMR0 Overflow Interrupt Enable bit = Enables    INTCONbits.TMR0IE =1;     // Global Interrupt Enable bit = Enables    INTCONbits.GIE = 1;    // start game    is_debug = !PORTAbits.RA1;    // button    is_digit[0] = false;    is_digit[1] = false;    is_digit[2] = false;    digit[0] = 2;    digit[1] = 1;    digit[2] = 0;    tone( DO5, 50, 50 );    status = ST_WAIT ;    // loop if push button    while( status == ST_WAIT ) {        upDigit(true);        __delay_ms(500);    }    // endless loop    while(1) {        if ( status == ST_BUTTON_1 ) {            noTone( 10 );            status = ST_PLAY_2 ;        } else if ( status == ST_BUTTON_2 ) {            noTone( 10 );            status = ST_PLAY_3 ;        } else if ( status == ST_BUTTON_3 ) {            endGame();        } else if (( status == ST_PLAY_1 )||( status == ST_PLAY_2 )||( status == ST_PLAY_3 )) {            tone( FA, 10, 3 );            tone( SO, 15, 3 );            tone( FA, 10, 3 );            tone( RA, 15, 3 );        }    }}
开发者ID:ohwada,项目名称:PIC16F84A,代码行数:53,


示例18: loop

void loop() {// establish variables for duration of the ping,// and the distance result in inches and centimeters:	long duration, inches, cm;// The PING))) is triggered by a HIGH pulse of 2 or more microseconds.// Give a short LOW pulse beforehand to ensure a clean HIGH pulse:	pinMode(pingPin, OUTPUT);	digitalWrite(pingPin, LOW);	delayMicroseconds(2);	digitalWrite(pingPin, HIGH);	delayMicroseconds(10);	digitalWrite(pingPin, LOW);// The same pin is used to read the signal from the PING))): a HIGH// pulse whose duration is the time (in microseconds) from the sending// of the ping to the reception of its echo off of an object.	pinMode(inPin, INPUT);	duration = pulseIn(inPin, HIGH);// convert the time into a distance	inches = microsecondsToInches(duration);	cm = microsecondsToCentimeters(duration);	Serial.println(cm, DEC);	if (cm < 3) {		// play the note corresponding to this sensor:		tone(8, notes[4], 30);	}	if ((cm >= 3) && (cm <= 9)) {		// play the note corresponding to this sensor:		tone(8, notes[0], 30);	}	if ((cm >= 10) && (cm <= 19)) {		// play the note corresponding to this sensor:		tone(8, notes[1], 30);	}	if ((cm >= 20) && (cm <= 29)) {		// play the note corresponding to this sensor:		tone(8, notes[2], 30);	}	if ((cm >= 30) && (cm <= 49)) {		// play the note corresponding to this sensor:		tone(8, notes[3], 30);	}	delay(100);}
开发者ID:Blair79,项目名称:ArduinoMega,代码行数:52,


示例19: beep2

void beep2(){  	digitalWrite(ledR, LOW);	tone(sirenPin, 4000);	delay(50);	noTone(sirenPin);	delay(50);	tone(sirenPin, 4000);	delay(1000);	noTone(sirenPin);	delay(500);	digitalWrite(ledR, HIGH);}
开发者ID:dome2048,项目名称:syc,代码行数:13,


示例20: bootDelay

static void bootDelay(){	const int soundFreq = 100;	const int bootTime = 7500;	const int bootPartTime = 500;	tone(pinPiezo, toneAccepted, soundFreq);	for (uint8_t i = 0; i < bootTime / bootPartTime; i++)	{		delay(bootPartTime);		wdt_reset();	}	tone(pinPiezo, toneAccepted, soundFreq);}
开发者ID:HackerspaceKRK,项目名称:zamek,代码行数:14,


示例21: millis

uint8_t ToneActuator::set_cmd(bool cmd) {  _last_cmd = millis();  bool actual_command = _is_active_low ? !cmd : cmd;  if (actual_command) {    if (_tone_duration > 0){      tone(_pin, _tone_frequency, _tone_duration);    }else{      tone(_pin, _tone_frequency);    }  }  else {    noTone(_pin);  }  return status_level;}
开发者ID:OpenAgInitiative,项目名称:openag_brain,代码行数:15,


示例22: builtin_setBeat

Call builtin_setBeat(Env parent_env, Args args) {    Number n = (Number)args_get(args, 0);    Closure k = (Closure)args_get(args, 1);    tone(PIEZO_PIN, (int)n->value);    delay(60000 / tempo);    return create_call(k, create_args(0));}
开发者ID:levsa,项目名称:compiler-tutorial,代码行数:7,


示例23: playtone

static voidplaytone(int pitch, int val, int sustain)/* play tone of proper duration for current rhythm signature */{    int	sound, silence, snum = 1, sdenom = 1;    /* this weirdness avoids floating-point arithmetic */    for (; sustain; sustain--)    {	snum *= NUM_MULT;	sdenom *= DENOM_MULT;    }    if (pitch == -1)	rest(whole * snum / (val * sdenom));    else    {	sound = (whole * snum) / (val * sdenom)		- (whole * (FILLTIME - fill)) / (val * FILLTIME);	silence = whole * (FILLTIME-fill) * snum / (FILLTIME * val * sdenom);#ifdef SPKRDEBUG	printf("playtone: pitch %d for %d ticks, rest for %d ticks/n",	    pitch, sound, silence);#endif /* SPKRDEBUG */	tone(pitchtab[pitch], sound);	if (fill != LEGATO)	    rest(silence);    }}
开发者ID:RyanLucchese,项目名称:rumpkernel-netbsd-src,代码行数:31,


示例24: loop

// the loop function runs over and over again forevervoid loop() {  ButtonMgr::update();  mainSM.run();  // Serial.println("And ON");  // digitalWrite(13, HIGH);   // turn the LED on (HIGH is the voltage level)  // delay(5000);              // wait for a second  // Serial.println("And OFF");  // digitalWrite(13, LOW);    // turn the LED off by making the voltage LOW  // delay(1000);              // wait for a second  // digitalWrite(RED_LED_PIN, !digitalRead(RED_BUTTON_PIN));  // digitalWrite(BLUE_LED_PIN, !digitalRead(BLUE_BUTTON_PIN));  // digitalWrite(YELLOW_LED_PIN, !digitalRead(YELLOW_BUTTON_PIN));  // digitalWrite(GREEN_LED_PIN, !digitalRead(GREEN_BUTTON_PIN));  //  //  if(    ButtonMgr::isPressed(RED_BUTTON_IDX)      || ButtonMgr::isReleased(RED_BUTTON_IDX) )  {    tone(SPEAKER_PIN, NOTE_A4, 250);  }}
开发者ID:thingsforhackers,项目名称:CopyMe,代码行数:26,


示例25: main

int main(void){	unsigned constrained = 0, shutOffBuzzer = 0;		//Set GPIO Pins	if(!shutOffBuzzer)		DDRB|=0b00100000; //PIN 13 output to buzzer		DDRB|=0b00001000;	sei();			setupADC();	setupPWM();	startPWM();		count=0;    InitTimer0();	StartTimer0();		while(1)    {			if(state)			pwm_val = remap(adc_val,100,900);		else		{		//0-255 steps for tone strength			constrained = remap(adc_val,619,890);					//Output tone			tone(constrained);		}	    }}
开发者ID:expectomas,项目名称:lab4part1,代码行数:33,


示例26: PlayMelody

void PlayMelody(int pin, char *notes, boolean (*af)()){  char nc, w ;  int n, t, l ;  pinMode(pin, OUTPUT) ;  _notEpointeR = notes ;  while ((nc = *_notEpointeR++) != '/0') {    if ((af != NULL) && (af() == false)) return ;    t = l = 0 ;    if ((nc >= 'a') && (nc <= 'z')) nc -= 32 ;#ifdef DEBUG    Serial.print(_tempO, DEC) ;    Serial.print(", ") ;    Serial.print(_octavE, DEC) ;    Serial.print(", ") ;    Serial.print(nc, BYTE) ;    Serial.print(", ") ;#endif    w = _wherEnotEchaR(nc) ;    if (w < 7) {      nc = _notEindeX[w] ;      w = _wherEnotEchaR(*_notEpointeR) ;      if ((w == 7) || (w == 8)) {        _notEpointeR++ ;        nc++ ;      }      if ((w == 9) || (w == 10)) {        _notEpointeR++ ;        nc-- ;      }      t = _notEratE[nc] * (55 << (_octavE - 1)) ;      w = 99 ;      tone(pin, t) ;    }    n = _tOnumbeR() ;    if ((t > 0) || (w == 11) || (w == 12)) {      if (w == 11) noTone(pin) ;      if (n == 0) n = _lengtH ;      l = 12000 / _tempO * 40 / n ;      if (*_notEpointeR == '.') {        _notEpointeR++ ;        l *= 1.5 ;      }    }    if ((w == 13) && (_octavE < 8)) _octavE++ ;    if ((w == 14) && (_octavE > 1)) _octavE-- ;    if ((w == 15) && (n >= 1) && (n <= 8)) _octavE = n ;    if ((w == 16) && (n >= 1) && (n <= 512)) _tempO = n ;    if ((w == 17) && (n >= 1) && (n <= 128)) _lengtH = n ;#ifdef DEBUG    Serial.print(t, DEC) ;    Serial.print(", ") ;    Serial.println(l, DEC) ;#endif    if (l > 0) delay(l) ;    noTone(pin) ;  }}
开发者ID:cheon7886,项目名称:ArduinoBox,代码行数:60,


示例27: boot_tone

void boot_tone (int pin){    // notes in the melody:    int melody[] = {        NOTE_C4, NOTE_G3,NOTE_G3, NOTE_A3, NOTE_G3,0, NOTE_B3, NOTE_C4    };    // note durations: 4 = quarter note, 8 = eighth note, etc.:    int noteDurations[] = {        4, 8, 8, 4,4,4,4,4    };    // iterate over the notes of the melody:    for (int thisNote = 0; thisNote < 8; thisNote++)    {        // to calculate the note duration, take one second        // divided by the note type.        //e.g. quarter note = 1000 / 4, eighth note = 1000/8, etc.        int noteDuration = 1000 / noteDurations[thisNote];        tone (pin, melody[thisNote], noteDuration);        // to distinguish the notes, set a minimum time between them.        // the note's duration + 30% seems to work well:        int pauseBetweenNotes = noteDuration * 1.30;        delay (pauseBetweenNotes);        // stop the tone playing:        noTone (pin);    }}
开发者ID:abperiasamy,项目名称:batty,代码行数:29,


示例28: playtone

/*  * Play tone of proper duration for current rhythm signature  */static voidplaytone(int pitch, int value, int sustain){	register int sound, silence, snum = 1, sdenom = 1;	/* this weirdness avoids floating-point arithmetic */	for (; sustain; sustain--) {		/* See the BUGS section in the man page for discussion */		snum *= NUM_MULT;		sdenom *= DENOM_MULT;	}	if (value == 0 || sdenom == 0)		return;	if (pitch == -1)		rest(whole * snum / (value * sdenom));	else {		sound = (whole * snum) / (value * sdenom)			- (whole * (FILLTIME - fill)) / (value * FILLTIME);		silence = whole * (FILLTIME-fill) * snum / (FILLTIME * value * sdenom);#ifdef DEBUG		(void) printf("playtone: pitch %d for %d ticks, rest for %d ticks/n",			pitch, sound, silence);#endif /* DEBUG */		tone(pitchtab[pitch], sound);		if (fill != LEGATO)			rest(silence);	}}
开发者ID:ppaeps,项目名称:freebsd-head,代码行数:35,


示例29: src_rect

void BattleAnimation::Draw() {	if (!screen) {		// Initialization failed		return;	}	if (frame >= (int) animation->frames.size())		return;	const RPG::AnimationFrame& anim_frame = animation->frames[frame];	std::vector<RPG::AnimationCellData>::const_iterator it;	for (it = anim_frame.cells.begin(); it != anim_frame.cells.end(); ++it) {		const RPG::AnimationCellData& cell = *it;		int sx = cell.cell_id % 5;		int sy = cell.cell_id / 5;		int size = large ? 128 : 96;		Rect src_rect(sx * size, sy * size, size, size);		Tone tone(cell.tone_red, cell.tone_green, cell.tone_blue, cell.tone_gray);		int opacity = 255 * (100 - cell.transparency) / 100;		double zoom = cell.zoom / 100.0;		DisplayUi->GetDisplaySurface()->EffectsBlit(			x + cell.x, y + cell.y,			size / 2, size / 2,			*screen, src_rect, 			opacity, tone,			zoom, zoom);	}}
开发者ID:glynnc,项目名称:Player,代码行数:29,


示例30: ackLight

void AccessControl::ackTone() {    ackLight();      tone(_buzzerPin, NOTE_A4);    delay(200);    noTone(_buzzerPin);}
开发者ID:ArthurGuy,项目名称:RFIDAccessControl,代码行数:7,



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


C++ top函数代码示例
C++ toluafix_pushusertype_ccobject函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。