Here is how to implement a granular synthesizer in C.
This is an extension of my step by step video on CS50's Lab 4 Volume problem, so check that out if any of this is unclear.
0:00 Setup
3:00 Getting necessary variables
12:05 Granulation
15:43 Testing and output
www.louispino.com