Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
timoinutilis committed Oct 11, 2019
2 parents 09f47c5 + 4cf0bb7 commit d45b99c
Show file tree
Hide file tree
Showing 45 changed files with 1,971 additions and 643 deletions.
2 changes: 1 addition & 1 deletion core/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#ifndef core_h
#define core_h

#define CORE_VERSION "0.16"
#define CORE_VERSION "1.0"

#include <stdio.h>
#include <stdbool.h>
Expand Down
98 changes: 79 additions & 19 deletions core/interpreter/cmd_audio.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,23 +33,23 @@ enum ErrorCode cmd_SOUND(struct Core *core)
if (nValue.type == ValueTypeError) return nValue.v.errorCode;

// comma
if (interpreter->pc->type != TokenComma) return ErrorExpectedComma;
if (interpreter->pc->type != TokenComma) return ErrorSyntax;
++interpreter->pc;

// wave value
struct TypedValue waveValue = itp_evaluateOptionalNumericExpression(core, 0, 3);
if (waveValue.type == ValueTypeError) return waveValue.v.errorCode;

// comma
if (interpreter->pc->type != TokenComma) return ErrorExpectedComma;
if (interpreter->pc->type != TokenComma) return ErrorSyntax;
++interpreter->pc;

// pulse width value
struct TypedValue pwValue = itp_evaluateOptionalNumericExpression(core, 0, 15);
if (pwValue.type == ValueTypeError) return pwValue.v.errorCode;

// comma
if (interpreter->pc->type != TokenComma) return ErrorExpectedComma;
if (interpreter->pc->type != TokenComma) return ErrorSyntax;
++interpreter->pc;

// length value
Expand Down Expand Up @@ -92,7 +92,7 @@ enum ErrorCode cmd_SOUND(struct Core *core)
// if (sValue.type == ValueTypeError) return sValue.v.errorCode;
//
// // TO
// if (interpreter->pc->type != TokenTO) return ErrorExpectedTo;
// if (interpreter->pc->type != TokenTO) return ErrorSyntax;
// ++interpreter->pc;
//
// // voice value
Expand All @@ -119,15 +119,15 @@ enum ErrorCode cmd_VOLUME(struct Core *core)
if (nValue.type == ValueTypeError) return nValue.v.errorCode;

// comma
if (interpreter->pc->type != TokenComma) return ErrorExpectedComma;
if (interpreter->pc->type != TokenComma) return ErrorSyntax;
++interpreter->pc;

// volume value
struct TypedValue volValue = itp_evaluateOptionalNumericExpression(core, 0, 15);
if (volValue.type == ValueTypeError) return volValue.v.errorCode;

// comma
if (interpreter->pc->type != TokenComma) return ErrorExpectedComma;
if (interpreter->pc->type != TokenComma) return ErrorSyntax;
++interpreter->pc;

// mix value
Expand Down Expand Up @@ -164,31 +164,31 @@ enum ErrorCode cmd_ENVELOPE(struct Core *core)
if (nValue.type == ValueTypeError) return nValue.v.errorCode;

// comma
if (interpreter->pc->type != TokenComma) return ErrorExpectedComma;
if (interpreter->pc->type != TokenComma) return ErrorSyntax;
++interpreter->pc;

// attack value
struct TypedValue attValue = itp_evaluateOptionalNumericExpression(core, 0, 15);
if (attValue.type == ValueTypeError) return attValue.v.errorCode;

// comma
if (interpreter->pc->type != TokenComma) return ErrorExpectedComma;
if (interpreter->pc->type != TokenComma) return ErrorSyntax;
++interpreter->pc;

// decay value
struct TypedValue decValue = itp_evaluateOptionalNumericExpression(core, 0, 15);
if (decValue.type == ValueTypeError) return decValue.v.errorCode;

// comma
if (interpreter->pc->type != TokenComma) return ErrorExpectedComma;
if (interpreter->pc->type != TokenComma) return ErrorSyntax;
++interpreter->pc;

// sustain value
struct TypedValue susValue = itp_evaluateOptionalNumericExpression(core, 0, 15);
if (susValue.type == ValueTypeError) return susValue.v.errorCode;

// comma
if (interpreter->pc->type != TokenComma) return ErrorExpectedComma;
if (interpreter->pc->type != TokenComma) return ErrorSyntax;
++interpreter->pc;

// release value
Expand Down Expand Up @@ -232,31 +232,31 @@ enum ErrorCode cmd_LFO(struct Core *core)
if (nValue.type == ValueTypeError) return nValue.v.errorCode;

// comma
if (interpreter->pc->type != TokenComma) return ErrorExpectedComma;
if (interpreter->pc->type != TokenComma) return ErrorSyntax;
++interpreter->pc;

// rate value
struct TypedValue rateValue = itp_evaluateOptionalNumericExpression(core, 0, 15);
if (rateValue.type == ValueTypeError) return rateValue.v.errorCode;

// comma
if (interpreter->pc->type != TokenComma) return ErrorExpectedComma;
if (interpreter->pc->type != TokenComma) return ErrorSyntax;
++interpreter->pc;

// osc amount value
struct TypedValue oscValue = itp_evaluateOptionalNumericExpression(core, 0, 15);
if (oscValue.type == ValueTypeError) return oscValue.v.errorCode;

// comma
if (interpreter->pc->type != TokenComma) return ErrorExpectedComma;
if (interpreter->pc->type != TokenComma) return ErrorSyntax;
++interpreter->pc;

// vol amount value
struct TypedValue volValue = itp_evaluateOptionalNumericExpression(core, 0, 15);
if (volValue.type == ValueTypeError) return volValue.v.errorCode;

// comma
if (interpreter->pc->type != TokenComma) return ErrorExpectedComma;
if (interpreter->pc->type != TokenComma) return ErrorSyntax;
++interpreter->pc;

// pw amount value
Expand Down Expand Up @@ -295,6 +295,8 @@ enum ErrorCode cmd_LFO_A(struct Core *core)
// LFO.A
++interpreter->pc;

// obsolete syntax!

// n value
struct TypedValue nValue = itp_evaluateNumericExpression(core, 0, NUM_VOICES - 1);
if (nValue.type == ValueTypeError) return nValue.v.errorCode;
Expand All @@ -307,7 +309,7 @@ enum ErrorCode cmd_LFO_A(struct Core *core)
}

// comma
if (interpreter->pc->type != TokenComma) return ErrorExpectedComma;
if (interpreter->pc->type != TokenComma) return ErrorSyntax;
++interpreter->pc;

union LFOAttributes attr;
Expand All @@ -325,6 +327,64 @@ enum ErrorCode cmd_LFO_A(struct Core *core)
return itp_endOfCommand(interpreter);
}

enum ErrorCode cmd_LFO_WAVE(struct Core *core)
{
struct Interpreter *interpreter = core->interpreter;

// LFO WAVE
++interpreter->pc;
++interpreter->pc;

// n value
struct TypedValue nValue = itp_evaluateNumericExpression(core, 0, NUM_VOICES - 1);
if (nValue.type == ValueTypeError) return nValue.v.errorCode;

// comma
if (interpreter->pc->type != TokenComma) return ErrorSyntax;
++interpreter->pc;

// wave value
struct TypedValue wavValue = itp_evaluateOptionalNumericExpression(core, 0, 3);
if (wavValue.type == ValueTypeError) return wavValue.v.errorCode;

// comma
if (interpreter->pc->type != TokenComma) return ErrorSyntax;
++interpreter->pc;

// inv value
struct TypedValue invValue = itp_evaluateOptionalNumericExpression(core, -1, 1);
if (invValue.type == ValueTypeError) return invValue.v.errorCode;

// comma
if (interpreter->pc->type != TokenComma) return ErrorSyntax;
++interpreter->pc;

// env value
struct TypedValue envValue = itp_evaluateOptionalNumericExpression(core, -1, 1);
if (envValue.type == ValueTypeError) return envValue.v.errorCode;

// comma
if (interpreter->pc->type != TokenComma) return ErrorSyntax;
++interpreter->pc;

// tri value
struct TypedValue triValue = itp_evaluateOptionalNumericExpression(core, -1, 1);
if (triValue.type == ValueTypeError) return triValue.v.errorCode;

if (interpreter->pass == PassRun)
{
int n = nValue.v.floatValue;
struct Voice *voice = &core->machine->audioRegisters.voices[n];

if (wavValue.type != ValueTypeNull) voice->lfoAttr.wave = wavValue.v.floatValue;
if (invValue.type != ValueTypeNull) voice->lfoAttr.invert = invValue.v.floatValue ? 1 : 0;
if (envValue.type != ValueTypeNull) voice->lfoAttr.envMode = envValue.v.floatValue ? 1 : 0;
if (triValue.type != ValueTypeNull) voice->lfoAttr.trigger = triValue.v.floatValue ? 1 : 0;
}

return itp_endOfCommand(interpreter);
}

enum ErrorCode cmd_PLAY(struct Core *core)
{
struct Interpreter *interpreter = core->interpreter;
Expand All @@ -337,7 +397,7 @@ enum ErrorCode cmd_PLAY(struct Core *core)
if (nValue.type == ValueTypeError) return nValue.v.errorCode;

// comma
if (interpreter->pc->type != TokenComma) return ErrorExpectedComma;
if (interpreter->pc->type != TokenComma) return ErrorSyntax;
++interpreter->pc;

// pitch value
Expand Down Expand Up @@ -437,7 +497,7 @@ enum ErrorCode cmd_TRACK(struct Core *core)
if (tValue.type == ValueTypeError) return tValue.v.errorCode;

// comma
if (interpreter->pc->type != TokenComma) return ErrorExpectedComma;
if (interpreter->pc->type != TokenComma) return ErrorSyntax;
++interpreter->pc;

// voice value
Expand Down Expand Up @@ -482,15 +542,15 @@ struct TypedValue fnc_MUSIC(struct Core *core)
++interpreter->pc;

// bracket open
if (interpreter->pc->type != TokenBracketOpen) return val_makeError(ErrorExpectedLeftParenthesis);
if (interpreter->pc->type != TokenBracketOpen) return val_makeError(ErrorSyntax);
++interpreter->pc;

// x value
struct TypedValue xValue = itp_evaluateExpression(core, TypeClassNumeric);
if (xValue.type == ValueTypeError) return xValue;

// bracket close
if (interpreter->pc->type != TokenBracketClose) return val_makeError(ErrorExpectedRightParenthesis);
if (interpreter->pc->type != TokenBracketClose) return val_makeError(ErrorSyntax);
++interpreter->pc;

struct TypedValue value;
Expand Down
1 change: 1 addition & 0 deletions core/interpreter/cmd_audio.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ enum ErrorCode cmd_VOLUME(struct Core *core);
enum ErrorCode cmd_ENVELOPE(struct Core *core);
enum ErrorCode cmd_LFO(struct Core *core);
enum ErrorCode cmd_LFO_A(struct Core *core);
enum ErrorCode cmd_LFO_WAVE(struct Core *core);
enum ErrorCode cmd_PLAY(struct Core *core);
enum ErrorCode cmd_STOP(struct Core *core);
enum ErrorCode cmd_MUSIC(struct Core *core);
Expand Down
Loading

0 comments on commit d45b99c

Please sign in to comment.