I've determined the cause of my issue, it wasn't due to how I was doing things, but due to my not connecting the grounds of 2 separate power sources together. From this I have learned to always post the wiring diagram when asking questions, because the issue might not be in the code.
Anyways for people who want to accomplish changing lights while also playing audio, here's some code that accomplishes that.
I don't have time to make a diagram at the moment, but here's how everything is wired:
for playing audio:
(except I used d9 for the output)
for the lights:
5v -> +5v
d7 -> resistor (220 Ω) -> data
gnd -> gnd
for SD card:
https://create.arduino.cc/projecthub/electropeak/sd-card-module-with-arduino-how-to-read-write-data-37f390
#include <SD.h>
#include <FastLED.h>
#include <TMRpcm.h>
#define SD_CS_PIN 10
#define LED_PIN 7
#define NUM_LEDS 50
CRGB leds[NUM_LEDS];
TMRpcm tmrpcm;
void setup() {
// Open serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial);
Serial.print("Initializing SD card...");
if (!SD.begin(SD_CS_PIN)) {
Serial.println("initialization failed. Things to check:");
Serial.println("1. is a card inserted?");
Serial.println("2. is your wiring correct?");
Serial.println("3. did you change the chipSelect pin to match your shield or module?");
Serial.println("Note: press reset or reopen this serial monitor after fixing your issue!");
while (true) {
delay(10000);
}
}
Serial.println("initialization done.");
// Initialize LEDs
FastLED.addLeds<WS2812, LED_PIN, GRB>(leds, NUM_LEDS);
// Start the song
tmrpcm.speakerPin = 9; //5,6,11 or 46 on Mega, 9 on Uno, Nano, etc
tmrpcm.setVolume(5);
tmrpcm.play("SONG.WAV");
}
long lastMillis = 0;
void loop() {
// cycle through red, green, blue on all lights, 200 ms delay
int colorList[3][3] = {{3, 0, 0}, {0, 3, 0}, {0, 0, 3}};
if (millis() - lastMillis > 200) {
for (int i = 0; i < NUM_LEDS; i++) {
leds[i] = CRGB(colorList[colorIdx][0], colorList[colorIdx][1], colorList[colorIdx][2]);
}
FastLED.show();
lastMillis = millis();
colorIdx = (colorIdx + 1) % 3;
}
}