Snippets

After putting a few modules together, I thought it helpful to start using snippets to manage the boilerplate. Here’s some YASnippets for creating modules.

# -*- mode: snippet -*-
# name: module header
# group: rack
# key: module
# --
struct ${1:Module}: public Module {
   enum ParamIds {
      NUM_PARAMS
   };
   enum InputIds {
      NUM_INPUTS
   };
   enum OutputIds {
      NUM_OUTPUTS
   };
   enum LightIds {
      NUM_LIGHTS
   };

   $1();
   virtual ~$1();

   virtual void step();
   virtual void onSampleRateChange();
   virtual void onReset();
   virtual void onRandomize();

   virtual json_t *toJson();
   virtual void fromJson(json_t* root);
};

# -*- mode: snippet -*-
# name: module implementation
# key: module
# group: rack
# --
${1:awesomesoup}::$1()
   : Module(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS)
{
}

$1::~$1() {
}

void $1::step() {
}

void $1::onSampleRateChange() {
}

void $1::onReset() {
}

void $1::onRandomize() {
}

json_t* $1::toJson() {
}

void $1::fromJson(json_t* root) {
}

Widgets for the modules, I don’t have snippets for yet. Have to clean them up.