File: tuning.h

package info (click to toggle)
lsp-plugins 1.2.5-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 91,856 kB
  • sloc: cpp: 427,831; xml: 57,779; makefile: 9,961; php: 1,005; sh: 18
file content (75 lines) | stat: -rw-r--r-- 2,626 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#pragma once

#include "../../plugin.h"
#include "../../events.h"
#include "../../string-sizes.h"

static CLAP_CONSTEXPR const char CLAP_EXT_TUNING[] = "clap.tuning.draft/2";

#ifdef __cplusplus
extern "C" {
#endif

// Use clap_host_event_registry->query(host, CLAP_EXT_TUNING, &space_id) to know the event space.
//
// This event defines the tuning to be used on the given port/channel.
typedef struct clap_event_tuning {
   clap_event_header_t header;

   int16_t port_index; // -1 global
   int16_t channel;    // 0..15, -1 global
   clap_id tunning_id;
} clap_event_tuning_t;

typedef struct clap_tuning_info {
   clap_id tuning_id;
   char    name[CLAP_NAME_SIZE];
   bool    is_dynamic; // true if the values may vary with time
} clap_tuning_info_t;

typedef struct clap_plugin_tuning {
   // Called when a tuning is added or removed from the pool.
   // [main-thread]
   void(CLAP_ABI *changed)(const clap_plugin_t *plugin);
} clap_plugin_tuning_t;

// This extension provides a dynamic tuning table to the plugin.
typedef struct clap_host_tuning {
   // Gets the relative tuning in semitones against equal temperament with A4=440Hz.
   // The plugin may query the tuning at a rate that makes sense for *low* frequency modulations.
   //
   // If the tuning_id is not found or equals to CLAP_INVALID_ID,
   // then the function shall gracefuly return a sensible value.
   //
   // sample_offset is the sample offset from the begining of the current process block.
   //
   // should_play(...) should be checked before calling this function.
   //
   // [audio-thread & in-process]
   double(CLAP_ABI *get_relative)(const clap_host_t *host,
                                  clap_id            tuning_id,
                                  int32_t            channel,
                                  int32_t            key,
                                  uint32_t           sample_offset);

   // Returns true if the note should be played.
   // [audio-thread & in-process]
   bool(CLAP_ABI *should_play)(const clap_host_t *host,
                               clap_id            tuning_id,
                               int32_t            channel,
                               int32_t            key);

   // Returns the number of tunings in the pool.
   // [main-thread]
   uint32_t(CLAP_ABI *get_tuning_count)(const clap_host_t *host);

   // Gets info about a tuning
   // [main-thread]
   bool(CLAP_ABI *get_info)(const clap_host_t  *host,
                            uint32_t            tuning_index,
                            clap_tuning_info_t *info);
} clap_host_tuning_t;

#ifdef __cplusplus
}
#endif