c# - 具有C#或同等功能的Arduino音频频谱

标签 c# audio arduino spectrum

我使用了带有arduino的msgeq7芯片,从所有连接在面包板上的音频插孔中分离音频。我有显示7个不同频率的代码,每个频率都有一个快速响亮的“响度”值。我想知道是否有人知道如何使用arduino中的数据在C#中创建图形频谱?只是一个7x6的网格,底部有绿色的点,顶部附近有红色的点,可以上下 float 以帮助可视化响度,这没什么复杂的。有人帮忙吗?

最佳答案

我不了解C#,但是您可以跳到处理https://processing.org/,它是基于Java构建的,但是很容易掌握。您可以使用处理与Arduino建立串行连接,并在它们之间发送数据,然后在您认为合适的情况下渲染处理中的数据。

示例Arduino代码:

void setup() {
  Serial.begin(9600);
  Serial.setTimeout(20);
  delay(100);
}

void loop() {
//send data over serial port
    Serial.println("Hello World");
    delay(50);
}

处理代码:
import processing.serial.*;

Serial myPort;
String val;

void setup() {
  smooth();
  size(300, 350);
//you may have to mess around with the value in brackets to get the right on.
//Try printling out all values in Serial.list() and find your Arduino port name
  String portName = Serial.list()[3];
  println(portName);
  myPort = new Serial(this, portName, 9600);
  myPort.bufferUntil('\n');
}

void draw(){
    //draw stuff
}

void serialEvent( Serial myPort) {
  //put the incoming data into a String - 
  //the '\n' is our end delimiter indicating the end of a complete packet
  val = myPort.readStringUntil('\n');
  //make sure our data isn't empty before continuing
  if (val != null) {
    //trim whitespace and formatting characters (like carriage return)
    val = trim(val);
    println(val);
  }
}

希望这可以帮助您入门。这些信息大部分来自Sparkfun Arduino处理教程https://learn.sparkfun.com/tutorials/connecting-arduino-to-processing
因此,如果您还有其他问题,请看一下。

关于c# - 具有C#或同等功能的Arduino音频频谱,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29651246/

相关文章:

Java - 检测应用程序是否输出声音

audio - 如何在OpenAL中设置 channel 增益?

使用带有 Arduino 的瑞士流量计计算脉冲,它是如何完成的?

c# - 将 HTML 表信息从 MVC View 传递到 Controller ?

c# - 如果作为单独的任务启动,有没有办法取消 Parallel.ForEach 循环

iphone - AVAssestReader 停止音频回调

c - Arduino - 为什么结构超出范围?

c++ - 使用表达式初始化数组

c# - 如何在不抛出异常的情况下取消等待超时的任务

C#:获取完整的桌面大小?