electro-smith / DaisySP

A Powerful DSP Library in C++
https://www.electro-smith.com/daisy
Other
903 stars 143 forks source link

feat: adds new granular player module and sampling folder #194

Closed viniciusfersil123 closed 11 months ago

viniciusfersil123 commented 1 year ago

Hi There ! I'm excited to share with you my latest contribution to the DaisySP project – the GranularPlayer module.

About the GranularPlayer

The GranularPlayer module is designed to playback arrays of samples offering independent control over time-stretching and pitch-shifting. Here are some key features:

Playback Speed Control: This module allows you to adjust the playback speed. You can, for example, set it to 1 for normal playback, 2 to double the original playback speed, 0.5 to halve the original speed, an so on, and also use negative values to play the sample in reverse.

Transposition: You can transpose the sample in cents (with 100 cents equal to one semitone).

Grain Size Control: You can adjust the grain size in milliseconds, ranging from 1 millisecond to your desired value. This capability lets you manipulate the granularity of your sound.

Dual Grains with Overlapping Envelopes: The GranularPlayer module is implemented using two grains of sound, each multiplied by a half cosine envelope with 180-degree phase difference. This design is inspired by the "grain.player~" object in Pure Data’s else lib, by Alexandre Porres, which, in turn, draws inspiration from the B section of an audio example in Miller Puckette's Pure Data examples.

Folder Organization

I've organized this module under a new "Sampling" folder. The reason behind this categorization is that the GranularPlayer module incorporates several features that didn't quite fit neatly into any of the existing categories within the DaisySP repository. The creation of the "Sampling" category serves a dual purpose. Firstly, it provides a logical home for this module, making it easier for developers and users to find and utilize it. Secondly, I hope that this new category can serve as an inspiration for other developers to explore and develop modules based on various sampling algorithms. I've also taken care of the necessary changes in the Makefile and CMakeLists.txt to ensure a seamless integration of the "Sampling" category into the DaisySP project.

Demonstration Video and Sample Sound Effect I am also sharing a demonstration video to showcase it in action. In the video, I am using a small array that contains the iconic sound effect of Super Mario growing after eating a mushroom. This choice was intentional, as it's both small enough to fit into the flash memory of the Daisy Seed and culturally recognizable, making it a fun sound to experiment with. The decision to use a small sample and an array pointer input, rather than a file system in SDRAM or an SD card module, is to keep the module as agnostic as possible. This way, users can easily pass a pointer to their array and the array's size, making it straightforward to integrate the GranularPlayer into their projects.

Showcase video

beserge commented 11 months ago

Looks great! Sorry we took so long to review it, we're going to be working hard in the future to keep up with our PRs and issues. I'd like to also commend you on a really well put together PR, even with a demo video, thanks for your hard work!

I went ahead and fixed the style check. In the future you can just run the util/fix_style.sh script before committing. Not your fault at all, since the action didn't run to alert you to it until I manually triggered it. In the future I'd like to set it up to just automatically fix style when a PR is merged anyways to avoid these situations.

All in all, nice work! :shipit:

viniciusfersil123 commented 11 months ago

Hi @beserge !

Thank you so much for your kind words and for taking the time to review and merge my GranularPlayer module PR! I truly appreciate the positive feedback and commendation on the well-put-together nature of the contribution.

I completely understand the need for style consistency, and I appreciate you fixing the style check. I'll be sure to run the util/fix_style.sh script before committing in the future. Your guidance on this is valuable, and I'm glad to be aware of it for future contributions.

I also want to express my gratitude for the dedication of the DaisySP community. The support and generosity demonstrated throughout this process have been inspiring. It's fantastic to be part of a community that values collaboration and continuous improvement.

Thank you once again for your hard work in maintaining the project and for the warm welcome to my contribution. I look forward to continued collaboration and contributing to the growth of the DaisySP project.

Best regards,

beserge commented 11 months ago

@viniciusfersil123

Thank you for your kind message and for your contribution. We have an awesome community here working on a great project, and I'm glad you can be a part of it!

Thanks again!