산업 제조
산업용 사물 인터넷 | 산업자재 | 장비 유지 보수 및 수리 | 산업 프로그래밍 |
home  MfgRobots >> 산업 제조 >  >> Manufacturing Technology >> 제조공정

EL 테이프 음악 시각화 - 아두이노로 사운드를 빛내다

부품 및 소모품

부품 수량
아두이노 우노 1
아두이노용 EL 실드 1
EL 테이프 - 녹색 1m 1
EL 테이프 - 빨강 1m 1
EL 테이프 - 파랑 1m 1

프로젝트 소개

EL 테이프 음악 시각화 - 아두이노로 사운드를 빛내다

씨드스튜디오(SeeedStudio) EL 실드와 아두이노 우노를 사용했으며, EL 테이프를 실드의 4개 채널 중 3개에 연결했습니다.

연결이 완료되면 코드를 업로드하고 음악을 재생하기만 하면 됩니다!

이 코드는 프로세싱(Processing)과 프로세싱 아두이노 라이브러리를 사용합니다. 둘 다 정상 작동하도록 설정해야 합니다.

설치 완료 후 아두이노 라이브러리를 프로세싱 스케치북 폴더의 libraries 폴더로 이동하고, 프로세싱 에디터에서 코드를 여세요.

BeatWrite 파일의 38번째 줄:

song = minim.loadFile("/home/paul/Music/dope.mp3", 2048);

를 컴퓨터의 로컬 MP3 파일 경로로 변경하고 재생 버튼을 누르세요!

코드

BeatWrite (자바 - 프로세싱용)

/**
 * BeatDetect 객체를 FREQ_ENERGY 모드로 사용하는 예제.
 * isKick, isSnare, isHat, isRange, isOnset(int)로 비트 추적 가능.
 * detect()를 연속적인 오디오 버퍼로 호출해 분석을 "틱"해야 함.
 * draw() 안에서 호출 가능하지만 일부 오디오 버퍼를 놓칠 수 있음.
 * AudioListener인 BeatListener를 구현해 시스템이 처리하는 모든 오디오 버퍼에서
 * detect()를 호출하되 버퍼 반복이나 누락 없이 동작하도록 함.
 * 전체 곡을 재생하므로 로딩이 다소 느릴 수 있음.
 */
import processing.serial.*;
import ddf.minim.*;
import ddf.minim.analysis.*;
import cc.arduino.*;

Minim minim;
AudioPlayer song;
BeatDetect beat;
BeatListener bl;
Arduino arduino;

int ledPin = 1;   // EL 채널 1 연결
int ledPin2 = 2;  // EL 채널 2 연결
int ledPin3 = 3;  // EL 채널 3 연결
float kickSize, snareSize, hatSize;

void setup() {
  size(512, 200, P3D);
  minim = new Minim(this);
  arduino = new Arduino(this, "/dev/ttyACM1", 57600);
  song = minim.loadFile("/home/paul/Music/dope.mp3", 2048);
  song.play();

  beat = new BeatDetect(song.bufferSize(), song.sampleRate());
  beat.setSensitivity(100);  // 300ms 감도 설정 (기본값 10)

  kickSize = snareSize = hatSize = 16;

  bl = new BeatListener(beat, song);
  textFont(createFont("Helvetica", 16));
  textAlign(CENTER);

  arduino.pinMode(ledPin+3, Arduino.OUTPUT);
  arduino.pinMode(ledPin2+3, Arduino.OUTPUT);
  arduino.pinMode(ledPin3+3, Arduino.OUTPUT);
}

void draw() {
  background(0);
  fill(255);

  if(beat.isKick()) {
    arduino.digitalWrite(ledPin+3, Arduino.HIGH);
    kickSize = 32;
  }
  if(beat.isSnare()) {
    arduino.digitalWrite(ledPin2+3, Arduino.HIGH);
    snareSize = 32;
  }
  if(beat.isHat()) {
    arduino.digitalWrite(ledPin3+3, Arduino.HIGH);
    hatSize = 32;
  }

  arduino.digitalWrite(ledPin+3, Arduino.LOW);
  arduino.digitalWrite(ledPin2+3, Arduino.LOW);
  arduino.digitalWrite(ledPin3+3, Arduino.LOW);

  textSize(kickSize);
  text("KICK", width/4, height/2);
  textSize(snareSize);
  text("SNARE", width/2, height/2);
  textSize(hatSize);
  text("HAT", 3*width/4, height/2);

  kickSize = constrain(kickSize * 0.95, 16, 32);
  snareSize = constrain(snareSize * 0.95, 16, 32);
  hatSize = constrain(hatSize * 0.95, 16, 32);
}

void stop() {
  song.close();
  minim.stop();
  super.stop();
}

BeatListener (자바 - 프로세싱용)

class BeatListener implements AudioListener {
  private BeatDetect beat;
  private AudioPlayer source;

  BeatListener(BeatDetect beat, AudioPlayer source) {
    this.source = source;
    this.source.addListener(this);
    this.beat = beat;
  }

  void samples(float[] samps) {
    beat.detect(source.mix);
  }

  void samples(float[] sampsL, float[] sampsR) {
    beat.detect(source.mix);
  }
}

제조공정

  1. 뮤직 와이어 스프링: 강도, 내구성 및 현대적 응용
  2. 시니어를 위한 UX 설계: 종합 가이드
  3. 디지털 메모리가 중요한 이유
  4. 만능 덕트 테이프: 강도, 유연성, 일상 활용법
  5. 클래식 주크박스의 유산과 진화
  6. 악보: 중세 필사본에서 현대 출판까지 – 산업 개요
  7. 바코드 스캐너: 기술, 설계 및 미래 트렌드
  8. C++ 주석: 가독성 높고 유지보수하기 좋은 코드 작성법
  9. 데이터 매트릭스 vs QR 코드: 비즈니스에 가장 적합한 것은?
  10. CNC G코드 필수 가이드: CNC 프로그래머를 위한 핵심 설명