0
  • 聊天消息
  • 系統(tǒng)消息
  • 評論與回復(fù)
登錄后你可以
  • 下載海量資料
  • 學(xué)習(xí)在線課程
  • 觀看技術(shù)視頻
  • 寫文章/發(fā)帖/加入社區(qū)
會(huì)員中心
創(chuàng)作中心

完善資料讓更多小伙伴認(rèn)識你,還能領(lǐng)取20積分哦,立即完善>

3天內(nèi)不再提示

如何使用Wekinator輸出播放Arduino的噪音

454398 ? 來源:工程師吳畏 ? 2019-07-31 08:49 ? 次閱讀

電路圖

將其中一個(gè)蜂鳴器的正極連接到Arduino的9針,將另一個(gè)蜂鳴器的正極連接到Arduino的10針。然后將兩個(gè)蜂鳴器的底片連接到Arduino的底部。

如何運(yùn)行程序

首先,在Arduino IDE的帖子末尾粘貼為Arduino提供的代碼并上傳代碼。

然后您需要從Wekinator的快速演練頁面下載草圖。

下載屏幕上的鼠標(biāo)控制示例。解壓縮并在處理中運(yùn)行草圖。該草圖將為Wekinator提供輸入。您將需要Wekinator輸出的另一個(gè)草圖。該草圖的代碼在本文末尾。將其粘貼到處理中并運(yùn)行它。兩個(gè)處理輸出窗口如下所示:

現(xiàn)在打開Wekinator并進(jìn)行如下圖所示的設(shè)置。將輸入和輸出設(shè)置為2.將類型設(shè)置為自定義,然后單擊“配置”。您還可以查看下面附帶的視頻以查看過程

當(dāng)您點(diǎn)擊“configure”時(shí),會(huì)打開一個(gè)新窗口,如下圖所示。在該窗口中設(shè)置設(shè)置,如下圖所示。

現(xiàn)在將處理窗口中的綠框拖到左下角,然后點(diǎn)擊“隨機(jī)”。開始錄制半秒。

將處理窗口中的綠色框拖到中間頂部,然后單擊“randomize”。開始錄制半秒。

將處理窗口中的綠框拖到右下角,然后單擊“隨機(jī)化”。之后,開始錄制半秒。

然后點(diǎn)擊“Train”,然后點(diǎn)擊“Run”?,F(xiàn)在,當(dāng)您在處理窗口中拖動(dòng)綠色框時(shí),Arduino會(huì)根據(jù)此發(fā)出噪音。

嘗試使用不同的界面進(jìn)行試驗(yàn),甚至嘗試使用此圖形界面合成器制作音樂。

處理代碼(Wekinator輸出)

import vsync.*; // Importing the library that will help us in sending and receiving the values from the Arduino

import processing.serial.*; // Importing the serial library

// Below libraries will connect and send, receive the values from wekinator

import oscP5.*;

import netP5.*;

// Creating the instances

OscP5 oscP5;

NetAddress dest;

ValueSender sender;

// These variables will be syncronized with the Arduino and they should be same on the Arduino side.

public int output;

public int output1;

void setup()

{

// Starting the serial communication, the baudrate and the com port should be same as on the Arduino side.

Serial serial = new Serial(this, “COM10”, 19200);

sender = new ValueSender(this, serial);

// Synchronizing the variables as on the Arduino side. The order should be same.

sender.observe(“output”);

sender.observe(“output1”);

// Starting the communication with wekinator. listen on port 12000, return messages on port 6448

oscP5 = new OscP5(this, 12000);

dest = new NetAddress(“127.0.0.1”, 6448);

}

// Recieve OSC messages from Wekinator

void oscEvent(OscMessage theOscMessage) {

if (theOscMessage.checkAddrPattern(“/wek/outputs”) == true) {

// Receiving the output from wekinator

float value = theOscMessage.get(0).floatValue(); // First output

float val = theOscMessage.get(1).floatValue(); // Second output

// Converting the output to int type

output = int(value);

output1 = int(val);

}

}

void draw()

{

// Nothing to be drawn for this example

}

Arduino代碼

#include // Including the library that will help us in receiving and sending the values from processing

ValueReceiver《2》 receiver; /*Creating the receiver that will receive up to 2 values.

Put the number of values to synchronize in the brackets */

/* The below two variables will be synchronized in the processing

and they should be same on both sides. */

int output;

int output1;

// Pin connected to buzzer

int buzzer = 9;

int buzzer1 = 10;

int i,j;

void setup()

{

/* Starting the serial communication because we are communicating with the

Arduino through serial. The baudrate should be same as on the processing side. */

Serial.begin(19200);

// Synchronizing the variables with the processing. The variables must be int type.

receiver.observe(output);

receiver.observe(output1);

// Defines the Buzzer pins as output

pinMode(buzzer,OUTPUT);

pinMode(buzzer1,OUTPUT);

}

void loop()

{

// Receiving the output from the processing.

receiver.sync();

// Making the buzzer to beep according to the output from the processing

tone(buzzer1, output);

delay(5);

noTone(buzzer1);

tone(buzzer,output1);

delay(5);

noTone(buzzer);

}

聲明:本文內(nèi)容及配圖由入駐作者撰寫或者入駐合作網(wǎng)站授權(quán)轉(zhuǎn)載。文章觀點(diǎn)僅代表作者本人,不代表電子發(fā)燒友網(wǎng)立場。文章及其配圖僅供工程師學(xué)習(xí)之用,如有內(nèi)容侵權(quán)或者其他違規(guī)問題,請聯(lián)系本站處理。 舉報(bào)投訴
  • Arduino
    +關(guān)注

    關(guān)注

    188

    文章

    6477

    瀏覽量

    188114
收藏 0人收藏

    評論

    相關(guān)推薦

    精密空調(diào)—精密空調(diào)噪音擾人?看降噪音妙招!

    精密空調(diào)在運(yùn)行過程中產(chǎn)生的噪音問題不容忽視,這不僅影響工作環(huán)境,還可能對機(jī)房設(shè)備運(yùn)行造成干擾。下面聊一下如何降低機(jī)房精密空調(diào)噪音。 一、精密空調(diào)噪音來源。 1、風(fēng)機(jī)噪音:精密空調(diào)的
    的頭像 發(fā)表于 02-05 15:15 ?97次閱讀
    精密空調(diào)—精密空調(diào)<b class='flag-5'>噪音</b>擾人?看降<b class='flag-5'>噪音</b>妙招!

    TLV320AIC3101內(nèi)部哪些寄存器可以消噪音?

    我們現(xiàn)在有一款DV應(yīng)用到TLV320AIC3101,現(xiàn)在在錄視頻后,用DV播放視頻的時(shí)候會(huì)有很規(guī)律的背景噪音,有一點(diǎn)像以前的電視機(jī)沒有信號的時(shí)候的噪音,降低電源紋波也沒有改善,將視頻拷貝到電腦上
    發(fā)表于 11-08 07:43

    tlvac3100輸出噪音是什么原因?qū)е碌模?/a>

    我是在dm6446上面移植了3100的驅(qū)動(dòng),以前是用的3104,移植后可以用alsa的aplay播放音樂,但是伴隨著很大的噪音,類似于收音機(jī)沒信號時(shí)的那種噪聲,我把dac進(jìn)行mute或則關(guān)掉speaker,音樂和噪音都沒有了,
    發(fā)表于 11-07 08:19

    TLV320AIC3106在將PC端采集的數(shù)據(jù)放倒芯片進(jìn)行播放的時(shí)候發(fā)現(xiàn)有大量噪音“咯吱咯吱“的聲音,為什么?

    :采樣的頻率8k,雙聲道 問題:在將音頻卡采集的數(shù)據(jù)在PC端進(jìn)行播放的時(shí)候很流暢,沒有噪音,但是在將PC端采集的數(shù)據(jù)放倒芯片進(jìn)行播放的時(shí)候發(fā)現(xiàn)有大量噪音“咯吱咯吱“的聲音,為了驗(yàn)證不是
    發(fā)表于 11-06 06:38

    TPA3110很大噪音是怎么回事?

    PVCC 采用15V供電,線路連接如圖,測試用的喇叭輸出具有很大的噪音,無輸入信號噪音也非常大,希望工作人員指出產(chǎn)品設(shè)計(jì)的缺陷
    發(fā)表于 10-28 08:11

    PCM2706播放的時(shí)候伴隨了噠噠噠的噪音怎么解決?

    我設(shè)計(jì)了一個(gè)基于PCM2706的USB音頻,接通后可以播放音頻文件,不過耳機(jī)聽到正常音頻中間夾雜著“噠噠噠”固定頻率的噪音。實(shí)在不明白,請教這個(gè)如何解決?RCA輸出到外置DAC設(shè)備,一樣會(huì)有。
    發(fā)表于 10-25 06:59

    PCM1770播放音頻的時(shí)候有白噪音怎么解決?

    我們通過根據(jù)PCM1770的技術(shù)文檔提供的基礎(chǔ)電路設(shè)計(jì)圖,其中的Vcc與Vhp共用0.1uF和10uF的電容。其余接法和器件參數(shù)一樣。 但在播放24KHz與32KHz的音頻文件的過程中使用耳機(jī)
    發(fā)表于 10-25 06:56

    PCM5121輸出接喇叭后噪音特別明顯怎么解決?

    PCM5121硬件模式,輸出1Vrms,播放音樂正常,THD-N和頻響參數(shù)都o(jì)k。但輸出接喇叭后噪音特別明顯,具體現(xiàn)象如下: 1.PCM5121供電后,不
    發(fā)表于 10-24 07:39

    前端的I2S信號導(dǎo)致PCM1794輸出噪音非常大,幾乎聽不到有效聲音,為什么?如何解決?

    抓到的I2S波形),現(xiàn)在后端無法正常解碼,PCM1794設(shè)置為16bit,大部分是噪音,但是也能聽出來播放的音樂是我們播放的歌曲。如果設(shè)置為24bit,全是噪音,設(shè)置為I2S,和Lef
    發(fā)表于 10-18 06:44

    使用TLV320AIC3101IRHBT芯片進(jìn)行音頻播放的過程中,會(huì)產(chǎn)生一個(gè)噪音,是什么原因?qū)е碌模?/a>

    我在使用TLV320AIC3101IRHBT芯片進(jìn)行音頻播放的過程中,我通過程序去播放wav音頻文件,發(fā)現(xiàn)每次啟動(dòng)程序,播放聲音的最開始,會(huì)產(chǎn)生一個(gè)噪音,類似“咔”的一聲,后面持續(xù)
    發(fā)表于 10-14 06:29

    使用pcm1808作為音頻ADC,錄音時(shí)發(fā)現(xiàn)全是噪音怎么解決?

    ,FMT=0 接上mic錄音后播放全是噪音,把mic拿掉,把1808模擬輸入全接地后錄音出來都是靜音的,但是接上mic就全是噪音,請幫忙看看有沒有去問題,謝謝! 原理圖如下:
    發(fā)表于 10-12 07:44

    TLV320AIC3104在輸出端并聯(lián)電容有噪音是怎么回事?

    TLV320AIC3104+TAS5411 1、配置成PCM(TDM)模式,貼了C4620,輸出噪音,去掉C4620后無噪音 2、配置成I2S模式,貼了C4620,無噪音。 3、T
    發(fā)表于 09-30 07:43

    反饋電容是否會(huì)將共模噪音轉(zhuǎn)換為輸出的差模噪音?

    請教下圖中差分放大電路的兩個(gè)電阻并聯(lián)的濾波電容對于兩端輸入的共模信號是否具有相同的濾波效果,反饋電容是否會(huì)將共模噪音轉(zhuǎn)換為輸出的差模噪音,謝謝!
    發(fā)表于 08-09 07:48

    輸出共模電感為什么會(huì)有噪音

    電子發(fā)燒友網(wǎng)站提供《輸出共模電感為什么會(huì)有噪音.docx》資料免費(fèi)下載
    發(fā)表于 07-04 17:06 ?1次下載

    ESP-IDF-V4.3.1播放8K采樣率提示音(機(jī)器生成女聲)伴隨尖銳噪音,怎么解決?

    ESP-IDF-V4.3.1,播放8K采樣率的提示音(機(jī)器生成女聲,音調(diào)較高)的時(shí)候,會(huì)有伴隨比較尖銳的噪音出現(xiàn),同樣的配置播放較為低沉的男聲時(shí)沒有這個(gè)問題。使用V2.3版本的ADF庫接口去
    發(fā)表于 06-19 07:19

    電子發(fā)燒友

    中國電子工程師最喜歡的網(wǎng)站

    • 2931785位工程師會(huì)員交流學(xué)習(xí)
    • 獲取您個(gè)性化的科技前沿技術(shù)信息
    • 參加活動(dòng)獲取豐厚的禮品