Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement dx21 style pitch EG #12

Open
vampirefrog opened this issue Jun 10, 2024 · 2 comments
Open

Implement dx21 style pitch EG #12

vampirefrog opened this issue Jun 10, 2024 · 2 comments
Assignees

Comments

@vampirefrog
Copy link
Owner

IMG_20240610_074756

@vampirefrog
Copy link
Owner Author

vampirefrog commented Oct 26, 2024

Add two timer modes: FM timer and PCM timer.

FM timer would use the chip's internal timers (A or B), and will be useful if fmtoy will run with real hardware. But we can use the chip emulation as well.

PCM timer will just use the sample rate to trigger timer events.

The timer events will be used to advance the LFO and the EG.

@vampirefrog
Copy link
Owner Author

vampirefrog commented Oct 26, 2024

Pseudo code for pcm timers:

struct timer {
  int numerator, denominator, remainder;
};
void timer_init(struct timer *t, int numerator, int denominator);
int timer_advance(struct timer *t, int num_samples, int *triggered);

void render(int num_samples) {
  int remaining_samples = num_samples;
  while(remaining_samples > 0) {
    int triggered = 0;
    int render_samples = timer_advance(t, remaining_samples, &triggered);
    remaining_samples -= render_samples;
    render_chip_samples(render_samples);
    if(triggered)
      lfo_tick()
  }
  
}

@vampirefrog vampirefrog self-assigned this Nov 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant