Formalizing Konnakol using Haskell - GSoC '22
Tags: gsoc, tidalcycles, haskell, music
Published: 2022-09-06 11:37:04

# Contents

1. [Project Description](# Project Description)
2. [Phase 1](# Phase 1)
3. [Phase 2](# Phase 2)
4. [Challenges and Learnings](# Challenges and Learnings)
5. [Future Work](# Future Work)
6. [Blogs](# Blogs)
7. [Link to Code](# Link to Code)

# Project Description

The major aim of the project was to create a system which could formalize the rules of [Konnakol](https://github.com/tidalcycles/konnakol-gsoc/blob/main/ABOUT_KONNAKOL.md). The system developed was then integrated with [Tidal Cycles](https://tidalcycles.org/).

This project was done with [Haskell](https://www.haskell.org/), under the mentorship of Alex McLean.

# Phase 1 

The first part of the project was to develop a system which could formalize the rules of Konnakol, validate as well as generate Konnakol compositions. The system was also capacitated to generate diagrams based on the compositions (sample diagrams can be found [here](https://github.com/tidalcycles/konnakol-gsoc/tree/main/samplediags). All code for this phase has been published as a Haskell package named [konnakol](https://hackage.haskell.org/package/konnakol).

Compositions generated can be converted for use in Tidal Cycles. We obtained audio samples that could be used from [Arthur Carabott](https://www.arthurcarabott.com/konnakkol/), and hence could listen to compositions. One can listen to sample compositions [here](https://github.com/tidalcycles/konnakol-gsoc/tree/main/audiosamples).

The code written during Phase 1 can be found [here](https://github.com/tidalcycles/konnakol-gsoc).

# Phase 2

The second part of the project was to try modify Tidal Cycles so that it could deal with beat-wise compositions. We were able to develop a sequence datatype in Tidal Cycles, and define alternative function definitions for many functions that are used by patterns.

The code written in this regard can be found [here](https://github.com/tidalcycles/Tidal/tree/topic-sequences). My contributions focused on designing, implementing and integrating the [Sequence module](https://github.com/tidalcycles/Tidal/blame/topic-sequences/src/Sound/Tidal/Sequence.hs) with the help of the [Context module](https://github.com/tidalcycles/Tidal/blame/topic-sequences/src/Sound/Tidal/Context.hs).

# Challenges and Learnings

The major challenge that I faced initially was understanding the logic within the code that was written by other contributors. Since this was my first time contributing to an open source project, it took me some time to get familiar with the overall process.

I would say that the Google Summer of Code has introduced me to the world of open source and given me the joy of being a part of something huge. I have evolved to become a better programmer in the last 16 weeks, and look forward to continue contributing. 

# Future Work

After coming up with the Sequence datatype, we have decided to try rewrite Tidal from scratch, removing redundancies and adding precise documentation.

The work done in this direction can be found [here](https://github.com/tidalcycles/Tidal/tree/cycseq/tidal-cycseq/src/Sound/Tidal2).

# Blogs

For full details on the above, please see the development blogs:

- [Part 0](https://dev.to/aravindmohandas/getting-started-with-gsoc-22-haskell-45c2) - Before Official Coding period
- [Part 1](https://dev.to/aravindmohandas/konnakol-compositions-using-haskell-gsoc-22-update-1-1m7c) - Weeks 1 - 4
- [Part 2](https://dev.to/aravindmohandas/visualising-konnakol-compositions-gsoc-22-update-2-16pc) - Weeks 5 - 8
- [Part 3](https://dev.to/aravindmohandas/adding-sequences-to-tidal-cycles-and-listening-to-konnakol-gsoc-22-update-3-22oj) - Weels 9 - 12

# Link to Code

- [Phase 1](https://github.com/tidalcycles/konnakol-gsoc)
- [Phase 2](https://github.com/tidalcycles/Tidal/tree/topic-sequences)