0
$\begingroup$

I have applied transformation(Constant Q Transformation) to my audio time domain signal, this gives me Frequency vs Time representation. Now, the CQT values consists of complex values(84*260), but python makes use of only magnitude values to plot. I saved obtained spectrogram as .png image, to do some image processing work. So when i read this saved image I get 224*341*3.

After Image processing work, Now I want to reconstruct back my audio time domain signal to check my work. To reconstruct back to audio domain time signal, first i will read the image, when i read my image I get 224*341*3 values.

I have the phase information of 84*260 resulted from CQT in the beginning. I know we have to make use of phase information to reconstruct the signal. S=Magnitude * Phase.

How would one really reconstruct back the audio signal with this criteria.

Am i doing anything wrong. Has people came across same situations?

I am using Python and librosa library for all the operations.

Edit:

I know librosa icqt has existing bug. Even if I do reconstruction in matlab, how would i tackle the different dimensions. Hope its clear now.

Code:

#load the audio
data_aud,sr_aud  = librosa.core.load(path)

#find the cqt
cqt = librosa.core.cqt(data_aud, sr=44100, hop_length=512, n_bins=84, bins_per_octave=12, tuning=None, norm=1, sparsity=0.01, window='hann', scale=True, pad_mode='reflect')

#take the phase information
mag, phase = librosa.core.magphase(cqt,power = 1)

#save the fig
a_add=librosa.display.specshow(cqt, sr= 44100)
plt.axis('off')
plt.savefig(path,transparent = True, bbox_inches = 'tight', pad_inches = 0)

#image processing
img = cv2.imread(path,1)
gray=cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)

#multiply the image data with phase????
#reconstruct
y =librosa.core.icqt(imageData, sr=44100, hop_length=512, fmin=None, bins_per_octave=12, tuning=None, filter_scale=1, norm=1, sparsity=0.01, window='hann', scale=True, amin=1e-06)
$\endgroup$
  • $\begingroup$ Hi Krish, and welcome to DSP.SE! I think it is not clear what your exact conditions are, and they are important to know for people to be able to help you. For example, you write that "[t]he CQT has 84*260 values", but what is "the CQT" in this case - to what signal did you apply it to obtain 84*260 values? $\endgroup$ – applesoup Feb 12 at 20:39
  • $\begingroup$ @applesoup I edited in more deeper way, hope its clear now. $\endgroup$ – Krish Feb 13 at 11:52
  • $\begingroup$ Can you post the code? $\endgroup$ – applesoup Feb 13 at 13:34
  • $\begingroup$ @applesoup Done! $\endgroup$ – Krish Feb 14 at 10:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.