99精品伊人亚洲|最近国产中文炮友|九草在线视频支援|AV网站大全最新|美女黄片免费观看|国产精品资源视频|精彩无码视频一区|91大神在线后入|伊人终合在线播放|久草综合久久中文

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

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

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

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

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

掃碼添加小助手

加入工程師交流群

設(shè)置Arduino Board

這個(gè)項(xiàng)目使用連接到Arduino Uno的五個(gè)按鈕。使用Arduino為按鈕建立連接,如下圖所示。

項(xiàng)目草圖

在輸入端,我們將有一個(gè)Arduino草圖和一個(gè)Processing草圖。 Arduino草圖將讀取五個(gè)按鈕的狀態(tài),并通過(guò)串行通信將其轉(zhuǎn)發(fā)到Processing。 Processing sketch將接收此數(shù)據(jù),并通過(guò)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接收五個(gè)連續(xù)輸出,并根據(jù)這些輸出發(fā)出聲音。

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

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

chuck FMSynth_5ContinousOutputs.ck

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

設(shè)置Wekinator

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

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

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

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

點(diǎn)擊 下一步 按鈕,您將看到此窗口:

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

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

同樣,記錄其他三個(gè)按鈕的樣本。

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

相關(guān)項(xiàng)目

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

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

    關(guān)注

    0

    文章

    11

    瀏覽量

    9139
  • Arduino
    +關(guān)注

    關(guān)注

    190

    文章

    6498

    瀏覽量

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

掃碼添加小助手

加入工程師交流群

    評(píng)論

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

    Made with KiCad(135):Echo - 開源的音樂播放器

    “? Echo 是一個(gè)開源硬件平臺(tái),專為音樂播放器設(shè)計(jì)。該項(xiàng)目的目標(biāo)是開發(fā)一款基于開源軟件并采用開源設(shè)計(jì)的高品質(zhì)音樂播放器。 ” ? Made with KiCad 系列將支持新的展示方式。直接將以
    的頭像 發(fā)表于 07-16 11:17 ?822次閱讀
    Made with KiCad(135):Echo - 開源的音樂<b class='flag-5'>播放器</b>

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

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

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

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

    海貝HiBy R1播放器體驗(yàn)

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

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

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

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

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

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

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

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

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

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

    作為一個(gè)愛聽音樂打發(fā)時(shí)間的玩家,我已經(jīng)習(xí)慣隨身攜帶一款小巧輕便的音樂播放器,從早期的CD播放器到現(xiàn)在的數(shù)碼播放器,它總能在不經(jīng)意間中給我?guī)?lái)簡(jiǎn)單的快樂。不管是逛街等人的時(shí)候,還是工作壓力大的時(shí)候
    的頭像 發(fā)表于 12-09 09:40 ?956次閱讀
    海貝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格式聲音總是有雜音,同一塊板子如果用播放器播放音頻 是沒有雜音的。 我用用飛思卡爾的某個(gè)ce系
    發(fā)表于 10-25 08:00

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

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

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

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

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

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

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

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