Hello Team,
I am trying to generate a spectrogram with the Multicolored with the Magnitude and Frequencies of audio.
But using this code I could able to only generate a mono-color spectrogram as shown in the below Image.

And Is there any way to generate a Multi-colored spectrogram like the one which I have shared below.

Below I have attached the source code of it, kindly check it and tell me If there is anything needs to update.
Thanks in advance!
private func getSpectrogramImageGenerationFromMicrophoneAudio(recordedURL : URL) {
let acqCtx = AcquisitionContext(fftSize: 1024, sampleRate: 44100)
acqCtx.frequencyStepForIndex(1)
let rawAudio = DataLoader.loadAudioSamplesArrayOf(Float.self, atUrl: recordedURL, sampleRate: 44100, channels: 1)
if rawAudio == nil {
return
}
let signalAudio = rawAudio!.chunks(acqCtx.fftSize)
let fftValues = signalAudio.map{ fft($0) }
let realValues = fftValues.map{ Array($0.real[0..<$0.real.count/2]) }
for i in 0..<acqCtx.fftSize {
acqCtx.frequencyStepForIndex(i)
}
let magnitudes = spectrogramValuesForSignal(input: rawAudio!, chunkSize: 512)
let image3 = ImageUtils.drawImageForMagnitudes1(magsArray: magnitudes)
DispatchQueue.main.async {
let spectrogramImage = image3?.flipped
let spectrogramImageJpeg = spectrogramImage?.jpegData(compressionQuality: 0)
print(spectrogramImageJpeg)
self.imgVwSpectrogram.image = spectrogramImage
}
}
Hello Team,


I am trying to generate a spectrogram with the Multicolored with the Magnitude and Frequencies of audio.
But using this code I could able to only generate a mono-color spectrogram as shown in the below Image.
And Is there any way to generate a Multi-colored spectrogram like the one which I have shared below.
Below I have attached the source code of it, kindly check it and tell me If there is anything needs to update.
Thanks in advance!