Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

23
LINES

< > BotCompany Repo | #1018698 // SineSoundSource

JavaX fragment (include) [tags: use-pretranspiled]

Transpiled version (71L) is out of date.

sclass SineSoundSource extends VF1<double[]> {
  double freq;
  double sampleRate = 44100;
  double step;
  double phase;
  
  *(double *freq, double *sampleRate) {
    calcStep();
  }
  
  *(double *freq) {
    calcStep();
  }
  
  void calcStep {
    step = pi()*2*freq/sampleRate;
  }
  
  public void get(double[] lr) {
    fillDoubleArray(lr, Math.sin(phase)*32767);
    phase += step;
  }
}

download  show line numbers  debug dex  old transpilations   

Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1018698
Snippet name: SineSoundSource
Eternal ID of this version: #1018698/9
Text MD5: 71ed2f620c2543c6708dcdc96359f2b9
Author: stefan
Category: javax / audio
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-10-17 21:31:53
Source code size: 418 bytes / 23 lines
Pitched / IR pitched: No / No
Views / Downloads: 396 / 1013
Version history: 8 change(s)
Referenced in: [show references]