Skip to content

Commit 6f3ef49

Browse files
committed
[FEAT] readme+err handling+dragdrop setup
1 parent 1d02131 commit 6f3ef49

File tree

4 files changed

+133
-57
lines changed

4 files changed

+133
-57
lines changed

README.md

+93-41
Original file line numberDiff line numberDiff line change
@@ -1,72 +1,124 @@
1-
# rAVen
1+
# rAVen
22

33
> [!NOTE]
4-
>
5-
> rAVen is currently a WIP
6-
>
4+
> rAVen is currently a **Work in Progress (WIP)**.
75
8-
Just making songs look cool
6+
### Just making AUDIO look and feel cool
97

10-
## Deps
8+
---
119

12-
clang (or any C compiler really)
10+
## Table of Contents
11+
1. [Dependencies](#deps)
12+
2. [C Libraries Used](#c-libs-used)
13+
3. [Understanding FFT](#understanding-fft)
14+
4. [Building rAVen](#building)
15+
- [Using Build Script](#using-build-script)
16+
- [Using Makefile](#using-makefile)
17+
- [Using CMake](#using-cmake)
18+
5. [FAQ](#faq)
19+
6. [License](#license)
1320

14-
bash
21+
---
1522

16-
## C libs used
23+
## <a id="deps"></a>Deps
1724

18-
-> raylib
25+
- **Clang / GCC**
26+
- **Bash**
27+
- [C libs](#c-libs-used)
1928

20-
-> math, complex, assert for FFT
29+
---
2130

22-
-> libavformat for metadata extraction
31+
## <a id="c-libs-used"></a>C Libraries Used
2332

24-
Other standard libs
33+
- **raylib**: For rendering and visualizing audio
34+
- **math, complex, assert**: For FFT (Fast Fourier Transform)
35+
- **libavformat**: For metadata extraction
36+
- Other standard C libraries
2537

26-
## UNDERSTANDING FFT
38+
---
2739

28-
Fast Fourier Transform is very cool and blends both maths and algorithms pretty well
40+
## <a id="understanding-fft"></a>Understanding FFT
2941

30-
Check the comments in the [FFT](https://github.com/nots1dd/rAVen/blob/main/fft.c) C file
42+
Fast Fourier Transform (FFT) is a powerful algorithm that blends math and algorithms beautifully.
3143

32-
## Building
44+
To dive deeper, check out the comments in the [FFT.c](https://github.com/nots1dd/rAVen/blob/main/fft.c) file to understand how FFT is used to analyze audio samples.
45+
46+
---
47+
48+
## <a id="building"></a>Building rAVen
3349

3450
> [!WARNING]
35-
>
36-
> Build Script is not available right now
37-
>
38-
> It is going under some changes
39-
>
40-
> Use Makefile instead
41-
>
42-
43-
Using the build script:
44-
45-
```sh
46-
chmod +x build.sh
51+
> The build script is currently unavailable as it's undergoing changes.
52+
> For now, use the **Makefile**.
53+
54+
### <a id="using-build-script"></a>Using the Build Script:
55+
```bash
56+
chmod +x build.sh
4757
./build.sh
48-
./raven
58+
./raven samples/sample-15s.wav
4959
```
5060

51-
Using Makefile:
52-
53-
```sh
61+
### <a id="using-makefile"></a>Using Makefile:
62+
```bash
5463
make
5564
./raven
5665
```
5766

58-
Using CMake:
59-
60-
```sh
67+
### <a id="using-cmake"></a>Using CMake:
68+
```bash
6169
cmake -S . -B build/
62-
cmake --build build/
63-
./build/raven
70+
cmake --build build/
71+
./build/raven samples/sample-15s.wav
6472
```
6573

74+
---
75+
76+
## <a id="faq"></a>FAQ
77+
78+
### 1. How does the math work?
79+
80+
Check out the [fft.c](https://github.com/nots1dd/raven/blob/main/fft.c) file to understand how **Fast Fourier Transform** is used to analyze audio samples.
81+
82+
---
83+
84+
### 2. What audio formats are supported?
85+
86+
rAVen supports all formats supported by [RAYLIB](https://github.com/raysan5/raylib).
87+
88+
> [!NOTE]
89+
> Although RAYLIB supports `.flac`, it's **not enabled by default**. To enable `.flac` support:
90+
>
91+
> - Go to `src/config.h` in raylib and uncomment the following line:
92+
> ```c
93+
> //#define SUPPORT_FILEFORMAT_FLAC 1
94+
> ```
95+
> Then follow the raylib documentation for building raylib with this change.
96+
97+
### 3. What color pallette does rAVen follow?
98+
99+
rAVen uses [GRUVBOX](https://github.com/morhetz/gruvbox) color schema
100+
This color schema is something I use daily and I have come to really like it
101+
102+
There may be a time in the future of rAVen where I may make the theme **customizable** but for now, hope you like GRUVBOX :)
103+
104+
---
105+
106+
### 3. Will rAVen integrate with audio services like PipeWire, ALSA, or PulseAudio?
107+
108+
rAVen aims to support these services eventually. The first priority will be **PipeWire**, with plans to explore **ALSA** and **PulseAudio** integration in the future.
109+
110+
---
111+
112+
## <a id="license"></a>License
113+
114+
rAVen is free and open-source software, licensed under the **GNU Lesser General Public License**. See the full [LICENSE](https://github.com/nots1dd/raven/blob/main/LICENSE) for more details.
115+
116+
---
117+
118+
### Screenshots
119+
66120
![raven1](https://github.com/user-attachments/assets/40ab07df-4f43-406d-b30f-77b133780d12)
67121
![raven2](https://github.com/user-attachments/assets/3aa6de17-62b4-4f64-9b35-31ec6d0fbb5b)
68122
![raven3](https://github.com/user-attachments/assets/51a291b7-12d6-41b1-af3d-52759791a093)
69123
70-
71-
72-
rAVen is free and open source software licensed under GNU Lesser General Public License [LICENSE](https://github.com/nots1dd/raven/blob/main/LICENSE)
124+
---

main.c

+40-16
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@
3838
#define GRUVBOX_PURPLE \
3939
(Color) { 211, 134, 155, 255 } // #d3869b
4040

41-
typedef struct
42-
{
43-
float left;
44-
float right;
45-
} Frame;
41+
/*typedef struct*/
42+
/*{*/
43+
/* float left;*/
44+
/* float right;*/
45+
/*} Frame;*/
4646

4747
typedef enum
4848
{
@@ -67,7 +67,7 @@ typedef struct
6767
********************************************************/
6868

6969
float freqs[N];
70-
Frame global_frames[4800] = {0};
70+
float global_frames[4800] = {0};
7171
size_t global_frames_count = 0;
7272
float in[N];
7373
float complex out[N];
@@ -170,12 +170,12 @@ void SwitchVisualizationModeBackward() { currentMode = (currentMode - 1) % NUM_M
170170
void callback(void* bufferData, unsigned int frames)
171171
{
172172

173-
Frame* fs = bufferData;
173+
float (*fs)[2] = bufferData;
174174

175175
for (size_t i = 0; i < frames; i++)
176176
{
177177
memmove(in, in + 1, (N - 1) * sizeof(in[0]));
178-
in[N - 1] = fs[i].left;
178+
in[N - 1] = (fs[i][0]+fs[i][1])/2;
179179
}
180180

181181
fft(in, 1, out, N);
@@ -651,6 +651,24 @@ int main(int argc, char* argv[])
651651
break;
652652
}
653653

654+
if (IsFileDropped()) {
655+
PauseMusicStream(music);
656+
FilePathList droppedFiles = LoadDroppedFiles();
657+
printf("File dropped\n");
658+
if (droppedFiles.count > 0) {
659+
const char *file_path = droppedFiles.paths[0];
660+
printf("%s", droppedFiles.paths[0]);
661+
StopMusicStream(music);
662+
UnloadMusicStream(music);
663+
music = LoadMusicStream(file_path);
664+
PlayMusicStream(music);
665+
SetMusicVolume(music, currentVolume);
666+
extract_metadata(file_path, &metadata);
667+
AttachAudioStreamProcessor(music.stream, callback);
668+
}
669+
UnloadDroppedFiles(droppedFiles);
670+
}
671+
654672
// Detect if the user clicks on the info button
655673
if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON) && IsMouseOverRectangle(infoButton))
656674
{
@@ -662,11 +680,17 @@ int main(int argc, char* argv[])
662680
{
663681
PauseMusicStream(music);
664682
OpenFileDialog();
665-
UnloadMusicStream(music);
666-
music = LoadMusicStream(selected_song);
667-
PlayMusicStream(music);
668-
extract_metadata(selected_song, &metadata);
669-
AttachAudioStreamProcessor(music.stream, callback);
683+
if (is_song_file(selected_song)) {
684+
UnloadMusicStream(music);
685+
music = LoadMusicStream(selected_song);
686+
PlayMusicStream(music);
687+
SetMusicVolume(music, currentVolume);
688+
extract_metadata(selected_song, &metadata);
689+
AttachAudioStreamProcessor(music.stream, callback);
690+
} else {
691+
printf("NOT A VALID SONG FILE\n");
692+
ResumeMusicStream(music);
693+
}
670694
}
671695
if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON) && IsMouseOverRectangle(helpButton))
672696
{
@@ -751,9 +775,9 @@ int main(int argc, char* argv[])
751775
handleVisualization(cell_width, screenHeight, screenWidth, m);
752776

753777
// Draw song title
754-
const char* songTitle = "rAVen";
755-
Vector2 titleSize = MeasureTextEx(font, songTitle, 40, 2);
756-
DrawTextEx(font, songTitle, (Vector2){screenWidth / 2 - titleSize.x / 2, 20}, 40, 2,
778+
const char* mainTitle = "rAVen";
779+
Vector2 titleSize = MeasureTextEx(font, mainTitle, 40, 2);
780+
DrawTextEx(font, mainTitle, (Vector2){screenWidth / 2 - titleSize.x / 2, 20}, 40, 2,
757781
GRUVBOX_BLUE);
758782

759783
// Draw song details
Binary file not shown.

samples/sample-15s.wav

3.23 MB
Binary file not shown.

0 commit comments

Comments
 (0)