一区二区三区三上|欧美在线视频五区|国产午夜无码在线观看视频|亚洲国产裸体网站|无码成年人影视|亚洲AV亚洲AV|成人开心激情五月|欧美性爱内射视频|超碰人人干人人上|一区二区无码三区亚洲人区久久精品

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

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

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

如何使用Arduino Processing和Wekinator按鈕更改聲音播放器的音高

454398 ? 來源:工程師吳畏 ? 2019-07-30 14:33 ? 次閱讀
加入交流群
微信小助手二維碼

掃碼添加小助手

加入工程師交流群

設(shè)置Arduino Board

這個項目使用連接到Arduino Uno的五個按鈕。使用Arduino為按鈕建立連接,如下圖所示。

項目草圖

在輸入端,我們將有一個Arduino草圖和一個Processing草圖。 Arduino草圖將讀取五個按鈕的狀態(tài),并通過串行通信將其轉(zhuǎn)發(fā)到Processing。 Processing sketch將接收此數(shù)據(jù),并通過OSC(開放式聲音控制)協(xié)議將其轉(zhuǎn)發(fā)給Wekinator。

Arduino Sketch

#define buttonPin1 6

#define buttonPin2 5

#define buttonPin3 4

#define buttonPin4 3

#define buttonPin5 2

int inByte = 0; // incoming serial byte

// the setup function runs once when you press reset or power the board

void setup() {

Serial.begin(115200);

pinMode(buttonPin1, INPUT);

pinMode(buttonPin2, INPUT);

pinMode(buttonPin3, INPUT);

pinMode(buttonPin4, INPUT);

pinMode(buttonPin5, INPUT);

establishContact(); // send a byte to establish contact until receiver

// responds

}

// the loop function runs over and over again forever

void loop() {

// if we get a valid byte, read button pins:

if (Serial.available() 》 0) {

// get incoming byte:

inByte = Serial.read();

// read the state of the pushbuttons:

int buttonState1 = digitalRead(buttonPin1);

int buttonState2 = digitalRead(buttonPin2);

int buttonState3 = digitalRead(buttonPin3);

int buttonState4 = digitalRead(buttonPin4);

int buttonState5 = digitalRead(buttonPin5);

Serial.write(buttonState1);

Serial.write(buttonState2);

Serial.write(buttonState3);

Serial.write(buttonState4);

Serial.write(buttonState5);

}

}

void establishContact() {

while (Serial.available() 《= 0) {

Serial.print(‘A’); // send a capital A

delay(300);

}

}

處理草圖

import processing.serial.*;

import oscP5.*;

import netP5.*;

OscP5 oscP5;

NetAddress dest;

Serial myPort; // The serial port

int[] serialInArray = new int[5]; // Where we‘ll put what we receive

int serialCount = 0; // A count of how many bytes we receive

int button1, button2, button3, button4, button5;

boolean firstContact = false; // Whether we’ve heard from the microcontroller

void setup() {

size(256, 256); // Stage size

noStroke(); // No border on the next thing drawn

// Print a list of the serial ports, for debugging purposes:

println(Serial.list());

// I know that the first port in the serial list on my mac

// is always my FTDI adaptor, so I open Serial.list()[0]。

// On Windows machines, this generally opens COM1.

// Open whatever port is the one you‘re using.

String portName = Serial.list()[0];

myPort = new Serial(this, portName, 115200);

/* start oscP5, sending messages at port 9000 */

oscP5 = new OscP5(this,9000);

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

}

void draw() {

//Send the OSC message

sendOsc();

}

void serialEvent(Serial myPort) {

// read a byte from the serial port:

int inByte = myPort.read();

// if this is the first byte received, and it’s an A,

// clear the serial buffer and note that you‘ve

// had first contact from the microcontroller.

// Otherwise, add the incoming byte to the array:

if (firstContact == false) {

if (inByte == ’A‘) {

myPort.clear(); // clear the serial port buffer

firstContact = true; // you’ve had first contact from the microcontroller

myPort.write(‘A’); // ask for more

}

}

else {

// Add the latest byte from the serial port to array:

serialInArray[serialCount] = inByte;

serialCount++;

// If we have 3 bytes:

if (serialCount 》 4 ) {

button1 = serialInArray[0];

button2 = serialInArray[1];

button3 = serialInArray[2];

button4 = serialInArray[3];

button5 = serialInArray[4];

// print the values (for debugging purposes only):

println(button1 + “&” + button2 + “&” + button3 + “&” + button4 + “&” + button5);

// Send a capital A to request new sensor readings:

myPort.write(‘A’);

// Reset serialCount:

serialCount = 0;

}

}

}

void sendOsc() {

OscMessage msg = new OscMessage(“/wek/inputs”);

msg.add((float)button1);

msg.add((float)button2);

msg.add((float)button3);

msg.add((float)button4);

msg.add((float)button5);

oscP5.send(msg, dest);

}

設(shè)置ChucK

在輸出端,我們可以使用ChucK從Wekinator接收五個連續(xù)輸出,并根據(jù)這些輸出發(fā)出聲音。

下載您正在使用的操作系統(tǒng)的FM Synthesis示例。

現(xiàn)在打開終端并轉(zhuǎn)到您放置它的目錄并輸入以下行:

chuck FMSynth_5ContinousOutputs.ck

Chuck將開始收聽Wekinator的輸出并接收輸出,它將改變聲音的音高。

設(shè)置Wekinator

現(xiàn)在打開Wekinator并對設(shè)置進(jìn)行以下調(diào)整:

將輸入設(shè)置為5并輸出為5

選擇輸出鍵入到所有連續(xù)

Wekinator將從Processing接收五個輸入,并在訓(xùn)練后將向Chuck發(fā)送五個不同的輸出。從那里,ChucK將根據(jù)Wekinator輸出產(chǎn)生不同的聲音。

點擊 下一步 按鈕,您將看到此窗口:

按第一個按鈕,然后單擊 隨機(jī)化 。開始錄制一秒鐘,它將記錄一些樣本。

按第二個按鈕,然后單擊 隨機(jī)化 的。然后記錄一秒。

同樣,記錄其他三個按鈕的樣本。

記錄五個樣本后,單擊在 火車 上訓(xùn)練Wekinator。然后單擊 運(yùn)行 ?,F(xiàn)在當(dāng)您按下按鈕時,程序?qū)⒏鶕?jù)您提供的輸入發(fā)出聲音。

相關(guān)項目

如何構(gòu)建Arduino演講者幾分鐘播放音樂

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

    關(guān)注

    0

    文章

    11

    瀏覽量

    9119
  • Arduino
    +關(guān)注

    關(guān)注

    189

    文章

    6495

    瀏覽量

    190444
收藏 人收藏
加入交流群
微信小助手二維碼

掃碼添加小助手

加入工程師交流群

    評論

    相關(guān)推薦
    熱點推薦

    基于STM32的音樂播放器電路+PCB源文件+源碼+論文等打包下載

    基于STM32的音樂播放器電路+PCB源文件+源碼+論文等打包,推薦下載!
    發(fā)表于 05-29 21:37

    【開源分享】用ESP32復(fù)刻一個iPod :便攜式音樂播放器Tangara

    Tangara是一款便攜式開源音樂播放器,硬件電路使用KiCad設(shè)計,而且它的外殼和固件也是100%開源,點擊閱讀原文或下載鏈接可跳轉(zhuǎn)下載。它通過3.5毫米耳機(jī)插孔或藍(lán)牙輸出高品質(zhì)聲音,電池續(xù)航
    的頭像 發(fā)表于 04-22 08:05 ?487次閱讀
    【開源分享】用ESP32復(fù)刻一個iPod :便攜式音樂<b class='flag-5'>播放器</b>Tangara

    Made with KiCad:Tangara 便攜式音樂播放器

    “ Tangara 是一款便攜式音樂播放器。它可通過 3.5 毫米耳機(jī)插孔或藍(lán)牙輸出高品質(zhì)音質(zhì),電池續(xù)航時間長。” Made with KiCad 系列將支持新的展示方式。直接將以下鏈接復(fù)制到
    發(fā)表于 04-16 14:01

    海貝HiBy R1播放器體驗

    之前分享過用接入便攜耳放來提升音質(zhì),讓手機(jī)端也能享受HiFi級的聽感體驗。這個方案對于沒有數(shù)碼播放器的初燒用戶來說,確實是種非常高效的方法。 但缺點也是有的,比如歌曲存放需要占用手機(jī)存儲空間,手機(jī)
    的頭像 發(fā)表于 01-24 11:27 ?1089次閱讀
    海貝HiBy R1<b class='flag-5'>播放器</b>體驗

    蛇年煥新,數(shù)字標(biāo)牌播放器點亮新春營銷

    春節(jié)期間,商場成為人們歡聚、購物的熱門場所。在商場入口處,大型數(shù)字標(biāo)牌展示著精心制作的新春廣告,高清畫質(zhì)將喜慶氛圍完美呈現(xiàn),流暢的切換效果瞬間將顧客帶入熱鬧的春節(jié)氣氛中。 借助數(shù)字標(biāo)牌播放器
    的頭像 發(fā)表于 01-24 11:26 ?358次閱讀
    蛇年煥新,數(shù)字標(biāo)牌<b class='flag-5'>播放器</b>點亮新春營銷

    將基于PC的MP3播放器軟件移植到ADSP-21262 SHARC處理

    電子發(fā)燒友網(wǎng)站提供《將基于PC的MP3播放器軟件移植到ADSP-21262 SHARC處理上.pdf》資料免費下載
    發(fā)表于 01-03 14:54 ?0次下載
    將基于PC的MP3<b class='flag-5'>播放器</b>軟件移植到ADSP-21262 SHARC處理<b class='flag-5'>器</b>上

    索尼發(fā)布空間現(xiàn)實顯示播放器新版本

    索尼于2024年12月發(fā)布適用于空間現(xiàn)實顯示屏ELF-SR1和ELF-SR2的空間現(xiàn)實顯示播放器新版本。
    的頭像 發(fā)表于 12-24 15:19 ?597次閱讀

    畢業(yè)設(shè)計競賽選題推薦 | 嵌入式Linux應(yīng)用之音樂播放器項目實戰(zhàn)(含文檔及源碼)

    01引言隨著數(shù)字化娛樂日益普及,音樂播放器作為人們生活中不可或缺的一部分,扮演著重要的角色。無論是通勤途中、健身鍛煉還是工作學(xué)習(xí),一個好用的音樂播放器都能為用戶提供愉悅的音頻體驗,豐富生活的同時也
    的頭像 發(fā)表于 12-23 16:50 ?863次閱讀
    畢業(yè)設(shè)計競賽選題推薦 | 嵌入式Linux應(yīng)用之音樂<b class='flag-5'>播放器</b>項目實戰(zhàn)(含文檔及源碼)

    海貝R1便攜音樂播放器開箱

    作為一個愛聽音樂打發(fā)時間的玩家,我已經(jīng)習(xí)慣隨身攜帶一款小巧輕便的音樂播放器,從早期的CD播放器到現(xiàn)在的數(shù)碼播放器,它總能在不經(jīng)意間中給我?guī)砗唵蔚目鞓?。不管是逛街等人的時候,還是工作壓力大的時候
    的頭像 發(fā)表于 12-09 09:40 ?857次閱讀
    海貝R1便攜音樂<b class='flag-5'>播放器</b>開箱

    AM3354處理wince系統(tǒng)調(diào)playsound播放聲音,有電流雜音怎么解決?

    335板子wince7系統(tǒng)下調(diào)用playsound接口播放wav格式聲音總是有雜音,同一塊板子如果用播放器播放音頻 是沒有雜音的。 同一塊板子wince6系統(tǒng)下調(diào)用playsoun
    發(fā)表于 10-29 06:46

    TLV320AIC3106335板子wince系統(tǒng)下調(diào)用playsound接口播放wav格式聲音總是有雜音,怎么解決?

    TLV320AIC3106335板子wince系統(tǒng)下調(diào)用playsound接口播放wav格式聲音總是有雜音,同一塊板子如果用播放器播放音頻 是沒有雜音的。 我用用飛思卡爾的某個ce系
    發(fā)表于 10-25 08:00

    變速播放器1和2的區(qū)別

    關(guān)于變速播放器1和2的區(qū)別,由于這里并未明確指出“變速播放器1”和“變速播放器2”具體指的是哪兩款軟件,因此我無法提供這兩款特定軟件之間的對比。不過,我可以從一般意義上探討變速播放器
    的頭像 發(fā)表于 10-14 09:48 ?630次閱讀

    步步高AB915D DVD播放器維修圖紙

    步步高AB915D DVD播放器采用ZIVA-4.1芯片方案
    發(fā)表于 09-29 10:18 ?1次下載

    為什么好的播放器還要配解碼

    好的播放器之所以需要配備解碼,是因為音頻和視頻文件的編碼和解碼是一個復(fù)雜的過程,涉及到多種技術(shù)和標(biāo)準(zhǔn)。解碼的作用是將壓縮的音頻和視頻數(shù)據(jù)還原成可以被播放設(shè)備識別和
    的頭像 發(fā)表于 09-23 18:02 ?3030次閱讀

    數(shù)字播放器和解碼

    數(shù)字播放器和解碼的組合能夠提供更優(yōu)質(zhì)的音頻體驗。數(shù)字播放器負(fù)責(zé)處理和傳輸音頻數(shù)據(jù),而解碼則負(fù)責(zé)將這些數(shù)據(jù)轉(zhuǎn)換為高質(zhì)量的模擬信號。它們的配合可以確保你聽到的音頻既清晰又真實。
    的頭像 發(fā)表于 09-06 17:35 ?2072次閱讀
    數(shù)字<b class='flag-5'>播放器</b>和解碼<b class='flag-5'>器</b>