<div align="center">
    <img src="https://devalang.com/images/devalang-logo.svg" alt="Devalang Logo" width="300" />
</div>

# Changelog

## Version 0.0.1-alpha.15 (2025-08-27)

### ✨ Language Features

- Added `automate` statement to schedule parameter automation (e.g. volume, pan, pitch) over time
  - Supports per-note automation via a `automate` map on note calls (e.g. `note(C4, { automate: { volume: { 0%: 0.0, 100%: 1.0 } } })`)
- Added `print` statement to ease debugging at runtime
- Added special variables and functions usable in expressions:
  - `$env.bpm`, `$env.beat`
  - `$math.sin(expr)`, `$math.cos(expr)`
  - `$env.position` (alias of beat), `$env.seed` (global session seed for deterministic randomness)
  - `$math.random(seed?)`, `$math.lerp(a, b, t)`
  - `$easing.*` functions for shaping values in [0,1]:
    - `linear`, `easeIn/Out/InOutQuad`, `easeIn/Out/InOutCubic`, `easeIn/Out/InOutQuart`,
      `easeIn/Out/InOutExpo`, `easeIn/Out/InOutBack`, `easeIn/Out/InOutElastic`, `easeIn/Out/InOutBounce`
  - `$mod.*` modulators for time-based control:
    - `lfo.sine(ratePerBeat)`, `lfo.tri(ratePerBeat)`, `envelope(attack, decay, sustain, release, t)`
- Added basic `for` loops and array literals
  - Example: `for i in [1, 2, 3]: print i`

### 🧠 Core Engine

- Implemented runtime automation in the audio renderer with linear envelope interpolation
- Per-note automation supported (volume, pan, pitch) and evaluated during rendering
- Fixed evaluator recursion guard and improved `$math.*` expression handling (prevents stack overflows)
- Minor ADSR defaults polish: ensure `sustain` defaults to `1.0`
- Evaluator now supports `$mod.*` and `$easing.*` calls (evaluated before `$math.*`) for richer automation
- Modularized `AudioEngine::insert_note` into small helpers (oscillator, ADSR computation, pan gains, envelope evaluation, stereo mix)
  - Reused helpers in `pad_samples` to reduce duplication
- Moved special variables/functions to a dedicated module: `core::audio::special`, and refactored the evaluator to use it
- Continued borrow-friendly refactors to avoid unnecessary clones and improve readability

### 🧩 Parser / Preprocessor

- Parser upgrades for operators `+ - * /`, parentheses and brackets
- Improved arrow-call parsing and map handling for multi-line values
- Resolvers: refined `call`/`spawn` resolution (better error messages with stack traces)

### 🧱 Architecture / Refactor

- Modularized audio interpreter (split by statement type); clearer responsibilities
- Reduced allocations by passing slices/borrows instead of cloning large structures
- Removed dead code and unused params across resolvers, handlers, and interpreter modules

### 🧰 Tooling / Build

- Resolved binary/lib artifact collision by renaming the internal library crate to `devalang_core`
- Warning sweep: build now compiles cleanly without Rust warnings (and fewer Clippy lints)
- Moved error collection helpers into a dedicated `utils::error` module

### 🐛 Fixes & Stability

- Prevent infinite recursion during numeric expression evaluation
- Stabilized renderer and interpreter timing when combining `loop`, `call`, and `spawn`

### ⚠️ Breaking changes

- Internal crate rename to `devalang_core` (no change to the CLI or WASM package names)

## Version 0.0.1-alpha.14 (2025-08-24)

### 🌎 Ecosystem

- Deployed "SSO" (Single Sign-On) for user authentication. [(https://sso.devalang.com)](https://sso.devalang.com) when using `devalang login`.

### 🧩 Language Features

- Added support for ADSR envelopes in synthesizers.
  - Example: `let mySynth = synth sine { attack: 0, decay: 50, sustain: 100, release: 50 }`
- Added support for `note` parameters in synthesizers.
  - Example: `mySynth -> note(C4, { duration: 500, velocity: 0.8, glide: true, slide: false })`

### 🧠 Core Engine

- Patched banks resolution with improved namespace handling. (declaring `bank <bank_author>.<bank_name>` and using `.<bank_name>.<bank_trigger>`)
- Patched `arrow_call` to correctly handle argument parsing and improve error reporting.
  - Implemented multi-line argument parsing for `arrow_call`.
  - Patched execution of `arrow_call` to ensure correct timing and execution order.
- Upgraded indent lexer to handle multi-line statements and improve indentation handling.
- Upgraded `parse_map_value` to handle multi-line values and improve parsing logic in Parser.
- Added `log_message_with_trace` function to log messages with informations when running commands with `debug` flag.

### 🧰 Commands

- Added `login` command to authenticate users to install protected or private packages.
- Refactored `install` command to support installing banks, presets and plugins.
  - `install bank <bank_author>.<bank_name>` to install a specific bank of sounds.
  - `install preset <preset_author>.<preset_name>` to install a specific preset.
  - `install plugin <plugin_author>.<plugin_name>` to install a specific plugin.
- Implemented `debug` and `compress` arguments for `build`, `check` and `play` commands.
  - `build --debug` to build the AST with debug information.
  - `check --debug` to check the syntax with debug information.
  - `play --debug` to play the audio with debug information.
  - `build --compress` to compress the output.
  - `check --compress` to compress the output.
  - `play --compress` to compress the output.

## Version 0.0.1-alpha.13 (2025-07-26)

### 🧩 Language Features

- Added support for `fn` directive to define functions in Devalang.
  - Example: `fn myFunction(param1, param2):`

### 🧠 Core Engine

- Patched `trigger`, `call`, and `spawn`, `renderer` to handle correct cursor time in the audio interpreter.
- Refactored audio engine and interpreter to handle correct timing and execution while using `loop`, `call`, and `spawn` statements.
- Refactored `trigger` effects to apply more effects to triggers.
  - Example: `.myTrigger auto { reverb: 0.25, pitch: 0.75, gain: 0.8 }`
- Refactored `preprocessor` to handle correct namespaced banks of sounds and triggers.
- Refactored `collect_errors_recursively` to provide detailed error reporting across nested statements.
- Optimized the `renderer` to handle silent buffers and improve performance.

### 🛠️ Utilities

- Added the `extract_loop_body_statements` utility for better loop handling.
- Improved logging for module variables and functions.

### 🧩 Web Assembly

- Patched `lib.rs` dependencies to ensure compatibility with the latest Rust and WASM standards.

## Version 0.0.1-alpha.12 (2025-07-21)

### 🧩 Language Features

- Implemented `trigger` effects to apply effects to triggers, allowing for more dynamic sound manipulation.
  - Example: `.myTrigger auto { reverb: 1.0, pitch: 1.5, gain: 0.8 }`

### 🧠 Core Engine

- Moved `utils::installer` to `installer::utils` to better organize the project structure.
- Set CLI dependencies as optional in `Cargo.toml` to allow for a cleaner build without CLI features.
- Patched `@load` relative path resolution to ensure correct loading of external resources.
- Patched `trigger` statement that was not correctly parsed when using namespaced banks of sounds.

### 🧩 Web Assembly

- Patched `lib.rs` dependencies to ensure compatibility with the latest Rust and WASM standards.

## Version 0.0.1-alpha.11 (2025-07-20)

### 📖 Documentation

- Removed old documentation, please refer to the [new documentation website](https://docs.devalang.com) for the latest information.

### ✨ Syntax

- Added namespaced banks of sounds, allowing for better organization and management of sound banks.
  - Example: `.808.myTrigger` to access a specific trigger in the `808` bank.
- Added support for beat durations in `triggers` statements, allowing for more precise timing control.
  - Example: `.myTrigger 1/4 { ... }` to trigger the sound every quarter beat.
- Added support for beat durations in `arrow_calls` statements, allowing for more precise timing control.
  - Example: `mySynth -> note(C4, { duration: 1/8 })` to play a note for an eighth beat.

### 🧠 Core Engine

- Implemented `bank` resolver to resolve banks of sounds in the code.
  - Example: `bank 808` will resolve to a bank of sounds named `808` if exists (check bank available command).

### 🧰 Commands

> Use the `bank 808` statement to access the default sounds and triggers !
> Then you can use `808.myTrigger` to access a specific trigger in the `808` bank.

- Added `bank` command to manage banks of sounds.

  - `bank list` to list installed banks of sounds.
  - `bank available` to list available banks of sounds for installation.
  - `bank info <bank_name>` to show information about a specific bank.
  - `bank remove <bank_name>` to remove a bank.
  - `bank update` to update all banks of sounds.
  - `bank update <bank_name>` to update a specific bank.

- Added `install` command to install banks of sounds.
  - `install bank <bank_name>` to install a specific bank of sounds.

### 🧪 Experimental

- Introduced lazy loading and namespace-based resolution of installed sound banks.

## Version 0.0.1-alpha.10 (2025-07-19)

### 📖 Documentation

- Updated [new documentation website](https://docs.devalang.com) with new features and examples.

### 🧠 Core Engine

- Patched `call`, `spawn` to handle correct cursor time.
- Patched `advance_char` to handle correct indentation and dedentation.
- Patched `bank` resolver to handle numbers in bank names.
- Patched `spawn` calls that was not calling a variable.

### 🧩 Web Assembly

- Added `load_wasm_module` function to the WASM module to load Devalang modules dynamically.
- Added `render_audio` function to the WASM module to render audio files.

## Version 0.0.1-alpha.9 (2025-07-14)

### ✨ Syntax

- Added support for `synth` directives to define synthesizer sounds directly in code  
  → Example:

  ```deva
  let mySynth = synth sine
  ```

### 🧠 Core Engine

- ✅ **Major refactor** of the resolution layer:

  - `condition`, `loop`, `group`, `trigger`, `call`, `spawn`, and `driver` were fully rewritten
  - Ensures **correct variable scoping**, **cross-module references**, and **imported symbol resolution**

- ✅ Audio interpreter updated:
  - `call` and `spawn` now execute correctly in parallel, preserving **temporal alignment** across groups

### 🧩 Language Features

- Improved `@import` behavior:
  - Modules can now be imported using **relative paths only**
  - No need for absolute or root-based imports

## Version 0.0.1-alpha.8 (2025-07-12)

### Syntax

- Implemented `if` directive to conditionally execute blocks of code.
- Implemented `else` directive to provide an alternative block of code when the `if` condition is not met.
- Implemented `else if` directive to provide additional conditions for the `if` directive.

### Core Components

- Implemented evaluator for audio statements, to execute conditional statements.
- Fixed `group` resolution and export issues.
- Implemented `Global Store` debugger to inspect variables by module for build command.
- Organized `TokenKind` and `StatementKind` enums for better clarity and maintainability.
- Refactored audio interpreter to handle the new syntax and directives.
- Refactored lexer to handle new directives and improve tokenization.
- Refactored parser to handle new directives and improve parsing logic.
- Added support for `call` and `spawn` execution of imported groups.
- Enforced scoped resolution of groups in `spawn` and `call` (must be imported in current module).

## Version 0.0.1-alpha.7 (2025-07-11)

## Examples

- Added examples in `examples` folder (group, loop, variables, index).

## Structure

- Moved `rust/audio` folder to `rust/core/audio` to better organize the project structure.

### Core Components

- Implemented `group` directive to define groups of sounds.
- Implemented `call` directive to call a group of sounds.
- Implemented `spawn` directive to spawn a group of sounds in parallel.
- Implemented `sleep` directive to pause execution for a specified duration.
- Patched line and column tracking in the lexer to ensure correct indentation handling.
- Patched string lexing advancing to handle first character correctly.

## Version 0.0.1-alpha.5 (2025-07-05)

### Syntax

- Fixed block parsing issues caused by missing or incorrect `Indent` / `Dedent` token detection.
- Indentation handling now triggers correctly at each newline.
- Improved reliability of nested blocks (e.g., inside `loop`) with consistent `Dedent` termination.

### Core Components

- Added full **WebAssembly (WASM)** support — Devalang can now be compiled for browser or Node.js environments.
- Prepared the ground for future IDE integrations (e.g., VSCode extension) by stabilizing core syntax parsing.

## Version 0.0.1-alpha.4 (2025-07-03)

### Audio Engine

- Integrated Audio Engine to handle audio playback and rendering.
- Implemented Audio Player to play audio files.
- Added support for audio playback with the `play` command.

### Commands

- Implemented `play` command to play Devalang files.

  - Added `--watch` option to watch for changes in files and automatically rebuild and play them. (once)
  - Added `--repeat` option to repeat the playback of the audio file. (infinite)

  Note : You cannot use `--watch` and `--repeat` options together. Use `--repeat` instead.

## Version 0.0.1-alpha.3 (2025-07-01)

- /!\ Major refactor of the project structure and module system /!\
- Refactored module system to support multiple modules and submodules.
- Patched all directives to be compatible with the new project structure.
- Prepared for the upcoming audio engine integration and sound rendering capabilities.
- Updated documentation to reflect the new project structure and features.

## Version 0.0.1-alpha.2 (2025-06-26)

### Commands

- Implemented `init` command to initialize a new Devalang project.
- Implemented `template` command to manage templates.
  - Added `list` subcommand to list available templates.
  - Added `info` subcommand to show information about a specific template.
- Implemented `watch` subcommand for the `build` and `check` command to watch for changes in files and automatically rebuild or check them.

### Core Components

- Implemented Config manager to handle configuration files.
  - Added support for `.devalang` configuration file as a TOML file.
- Implemented File System watcher to monitor file changes.
- Implemented Template manager to handle templates and their metadata.

### Syntax

- Added support for built-in triggers for `.snare`, `.hihat`, `.clap`, `.tom`, `.crash`, `.ride`, `.synth`, `.bass`, and `.pad`.

## Version 0.0.1-alpha.1 (2025-06-25)

### Syntax

- Added support for `@import` directive to import other Devalang files.
- Added support for `@export` directive to export variables and functions.
- Added support for `@load` directive to load external resources.
- Added support for `bpm` directive to set the beats per minute.
- Added support for `bank` directive to define a bank of sounds.
- Added support for `loop` directive to define loops in the code.

### Commands

- Implemented `check` command to check the syntax of Devalang files.
- Implemented `build` command to build the Abstract Syntax Tree (AST) of Devalang files.

### Core Components

- Implemented Lexer to tokenize Devalang source code.
- Implemented Parser to parse the tokens and build the AST.
- Implemented Preprocessor to handle directives and preprocess the source code.
- Implemented Debugger to debug Devalang code.
- Implemented Builder to build the final output from the AST.
