Music Visualizer

Dependencies:   mbed SDFileSystem NeoStrip PinDetect

Revision:
3:da22ac4e975b
Parent:
2:d4a4704f3311
--- a/main.cpp	Thu Apr 30 02:02:04 2020 +0000
+++ b/main.cpp	Thu Apr 30 02:05:12 2020 +0000
@@ -6,15 +6,15 @@
 #include "rtos.h"
 #include <string>
 #include <vector>
- 
+
 # define MAX_FILE 30
- 
+
 #define N 40
 NeoStrip strip(p21, N);
- 
+
 //BusOut myleds(LED1,LED2,LED3,LED4);
 DigitalOut myled(LED1);
- 
+
 DigitalIn b2(p29, PullUp);
 Serial pc(USBTX, USBRX);
 SDFileSystem sd(p5, p6, p7, p8, "sd");
@@ -23,18 +23,18 @@
 wave_player waver(&speaker);
 Serial bt(p28, p27);      // Bluetooth
 DigitalOut mute(p29);          // mute pin (low for shutdown)
- 
+
 PwmOut spk(p24);
- 
+
 Thread thread1;
 Thread thread2;
 Thread thread3;
 Mutex sd_mtx;
 volatile int src = 0;  // 0 for Mic, 1 for SD card
- 
+
 vector<string> filenames;               // list of files in sd card
 volatile int cur_song = 1;
- 
+
 void read_file_names(char *dir) {
     DIR *dp;
     struct dirent *dirp;
@@ -44,7 +44,7 @@
     }
     closedir(dp);
 }
- 
+
 class microphone
 {
 public :
@@ -68,11 +68,11 @@
 }
  
 microphone mymicrophone(p16);
- 
+
 uint8_t r = (uint8_t)0;
 uint8_t g = (uint8_t)128;
 uint8_t b = (uint8_t)0;
- 
+
 int red, green, blue;
  
 // fancy function to make rainbow colors on LEDs
@@ -102,10 +102,10 @@
     uint8_t R = (uint8_t)(r * 255);
     uint8_t G = (uint8_t)(g * 255);
     uint8_t B = (uint8_t)(b * 255);
- 
+
     return (R << 16) | (G << 8) | B;
 }
- 
+
 // convert float values to LED otuput for soundtest array
 void float2LED(float value){
     float fnumLED = abs((value - 0.5)/3.3)*100; // can mess with this scaling for better LED output
@@ -144,7 +144,7 @@
     if (x > 360)
         x = 0;
 }
- 
+
 // same thing but for the mic
 void mic2LED(int mic){
     static float dh = 360.0 / 5;
@@ -180,7 +180,7 @@
     if (x > 360)
         x = 0; 
 }
- 
+
  
 void sound_thread() {
     FILE *wave_file;
@@ -194,7 +194,7 @@
     Thread::yield();
 }
     
- 
+
     
 unsigned short max_range = 0xFFFF;
 // function that calls above functions
@@ -250,7 +250,7 @@
             }
         }
 }
- 
+
 void bt_thread() {
     char bnum = 0;
     char bhit = 0;
@@ -335,10 +335,10 @@
         Thread::wait(100);
     }
 }
- 
+
 int main() {
     read_file_names("/sd/songs");
- 
+
     strip.setBrightness(0.05);
     
     mute = 1;
@@ -351,4 +351,5 @@
         myled = !myled;
         Thread::wait(100);
     }
-}
\ No newline at end of file
+}
+