Trying to open MIDI File instead of text file?

Hello! I’m working on my own project, and I’m trying to find out how to save a midi file to an array, which is similar to what is discussed in lecture 69 with saving a text file to an array. I have the implementation setup, but I can’t figure out why my UE_LOGs aren’t working. Is there a problem with my code? Any help or advice is appreciated.

// Called when the game starts or when spawned
void APianoBase::BeginPlay()
{
	Super::BeginPlay();

	//Setup of midifile path
	const FString MidiFilePath = FPaths::ProjectContentDir() / TEXT("MidiFiles/test.mid");

	//Filemanager used to deal with the file
	IPlatformFile& FileManager = FPlatformFileManager::Get().GetPlatformFile();

	//Load midi binary file to array 
	if (FileManager.FileExists(*MidiFilePath))
	{
		if(FFileHelper::LoadFileToArray(MidiFile, *MidiFilePath))
		{
			UE_LOG(LogTemp, Warning, TEXT("FILE MANIPULATION: File Loaded Successfully"));
			return;
		}
		else
		{
			UE_LOG(LogTemp, Warning, TEXT("FILE MANIPULATION: Did not load text from file"));
		}
	}
	else
	{
		UE_LOG(LogTemp, Warning, TEXT("FILE MANIPULATION ERROR: Can not read the file because it was not found."));
		UE_LOG(LogTemp, Warning, TEXT("FILE MANIPULATION ERROR: Expected file location at %s"), *MidiFilePath);
	}
}

Output Log:

Well you have logs in all places so there should be something. Are you sure there’s an instance of this class in the world?

Yes, I have placed an actor component in the world, and yet there are no logs firing. Is the file manager the problem? I also used this tutorial to help me with reading files if that helps with anything.

What about a log right at the start of BeginPlay? If that doesn’t work try rebuilding.

Privacy & Terms