Skip to content

Commit

Permalink
V 1.0.1 (#12)
Browse files Browse the repository at this point in the history
* v-1.0.1

* Changed deployment to production
  • Loading branch information
bkraad47 authored Jul 26, 2024
1 parent a9c8324 commit b7cde0f
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 25 deletions.
7 changes: 4 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ share/python-wheels/
*.egg
MANIFEST
.github
.github/*
.github/workflows/
.github/workflows/*

# Don't ignore .github/workflows
!.github/
!.github/workflows/

# PyInstaller
# Usually these files are written by a python script from a template
Expand Down
15 changes: 8 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ This will upscale the MP3 file specified in the example and produce a FLAC file

## Spectrogram Results

![Spectrogram Results](https://drive.google.com/uc?export=view&id=1Y-NHkwrSfrVexH1yYtzxcLOWQuLdvScL)
![Spectrogram Results](https://drive.google.com/uc?export=view&id=1_QgMQ8FR1Rryyw22bBQa0EAEGIjw9eS_)

## How it works

Expand Down Expand Up @@ -106,16 +106,17 @@ The report titled "Fast Sparse Fourier Transformations for NMR Spectroscopy" by

ericzo - beyond link(https://soundcloud.com/ericzomusic/free-electro-trap-anthem-beyond)

## Run Tests

Clone the repository and install the requirements. Test the packaged files:
```
python -m unittest discover -s fat_llama/tests
```
## Changelog

All notable changes to this project will be documented in this file.

### [1.0.1] - 2024-07-26

#### Changed

- Updated `analytics.py` analysis and spectorgram results.
- Updated `README.md` details.

### [1.0.0] - 2024-07-25

#### Added
Expand Down
34 changes: 21 additions & 13 deletions analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ def read_flac(file_path):
def normalize(signal):
return signal / np.max(np.abs(signal))

def compare_signals(mp3, flac):
def compare_signals(mp3, flac, sample_rate):
# Normalize signals
mp3 = normalize(mp3)
flac = normalize(flac)

min_len = min(len(mp3), len(flac))
mp3 = mp3[:min_len]
flac = flac[:min_len]
time = np.arange(min_len)
time = np.arange(min_len) / sample_rate

print(f"MP3 (first 10 samples): {mp3[:10]}")
print(f"FLAC (first 10 samples): {flac[:10]}")
Expand All @@ -40,7 +40,7 @@ def compare_signals(mp3, flac):
plt.plot(time, mp3, label='MP3')
plt.plot(time, flac, label='FLAC')
plt.legend()
plt.xlabel('Time')
plt.xlabel('Time (s)')
plt.ylabel('Amplitude')
plt.title('Waveform Comparison')
plt.show()
Expand All @@ -50,7 +50,7 @@ def compare_signals(mp3, flac):
plt.figure(figsize=(14, 7))
plt.plot(time, difference_signal, label='Difference Signal')
plt.legend()
plt.xlabel('Time')
plt.xlabel('Time (s)')
plt.ylabel('Amplitude')
plt.title('Difference Signal')
plt.show()
Expand All @@ -60,21 +60,28 @@ def compare_signals(mp3, flac):
print(f"Mean Squared Error: {mse}")

# 4. Spectrogram Comparison
f1, t1, Sxx1 = signal.spectrogram(mp3)
f2, t2, Sxx2 = signal.spectrogram(flac)
nperseg = 2048
f1, t1, Sxx1 = signal.spectrogram(mp3, fs=sample_rate, nperseg=nperseg)
f2, t2, Sxx2 = signal.spectrogram(flac, fs=sample_rate, nperseg=nperseg)

plt.figure(figsize=(14, 7))
plt.subplot(2, 1, 1)
plt.pcolormesh(t1, f1, 10 * np.log10(Sxx1))
plt.pcolormesh(t1, f1, 10 * np.log10(Sxx1), vmin=-120, vmax=0)
plt.title('Spectrogram of MP3')
plt.ylabel('Frequency [Hz]')
plt.xlabel('Time [sec]')
plt.ylabel('Frequency (Hz)')
plt.xlabel('Time (s)')
plt.colorbar(label='SNR (dB)')
plt.yscale('log')
plt.ylim(20, 25000)

plt.subplot(2, 1, 2)
plt.pcolormesh(t2, f2, 10 * np.log10(Sxx2))
plt.pcolormesh(t2, f2, 10 * np.log10(Sxx2), vmin=-120, vmax=0)
plt.title('Spectrogram of FLAC')
plt.ylabel('Frequency [Hz]')
plt.xlabel('Time [sec]')
plt.ylabel('Frequency (Hz)')
plt.xlabel('Time (s)')
plt.colorbar(label='SNR (dB)')
plt.yscale('log')
plt.ylim(20, 25000)
plt.tight_layout()
plt.show()

Expand Down Expand Up @@ -126,4 +133,5 @@ def compare_signals(mp3, flac):
else:
mp3 = resample(mp3, len(flac))

compare_signals(mp3, flac)
sample_rate = sample_rate_mp3 # Assuming both are the same after resampling
compare_signals(mp3, flac, sample_rate)
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setup(
name='fat_llama',
version='1.0.0',
version='1.0.1',
packages=find_packages(),
install_requires=[
'numpy',
Expand All @@ -28,7 +28,7 @@
long_description_content_type='text/markdown',
url='https://github.com/bkraad47/fat_llama',
classifiers=[
'Development Status :: 3 - Alpha',
'Development Status :: 5 - Production/Stable',
'Intended Audience :: Developers',
'License :: OSI Approved :: BSD License',
'Programming Language :: Python :: 3.9',
Expand Down

0 comments on commit b7cde0f

Please sign in to comment.