All files / src/shared/lib/uge song.ts

100% Statements 25/25
100% Branches 0/0
100% Functions 6/6
100% Lines 19/19

Press n or j to go to the next uncovered block, b, p or k for the previous block.

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                    32x   32x 1024x               32x 2880x               32x 24x                                         32x 285x 285x 285x     32x 285x 285x 285x     32x 285x 285x 285x    
/* eslint-disable camelcase */
import {
  Song,
  PatternCell,
  SubPatternCell,
  DutyInstrument,
  WaveInstrument,
  NoiseInstrument,
} from "./types";
 
const LAST_VERSION = 6;
 
export const createPatternCell = (): PatternCell => {
  return {
    note: null,
    instrument: null,
    effectcode: null,
    effectparam: null,
  };
};
 
export const createSubPatternCell = (): SubPatternCell => {
  return {
    note: null,
    jump: null,
    effectcode: null,
    effectparam: null,
  };
};
 
export const createSong = (): Song => {
  return {
    version: LAST_VERSION,
    name: "",
    artist: "",
    comment: "",
    filename: "song",
 
    duty_instruments: [],
    wave_instruments: [],
    noise_instruments: [],
    waves: [],
    ticks_per_row: 6,
 
    timer_enabled: false,
    timer_divider: 0,
 
    patterns: [],
    sequence: [],
  };
};
 
export const addDutyInstrument = (song: Song, instrument: DutyInstrument) => {
  const list = song.duty_instruments;
  instrument.index = list.length;
  list.push(instrument);
};
 
export const addWaveInstrument = (song: Song, instrument: WaveInstrument) => {
  const list = song.wave_instruments;
  instrument.index = list.length;
  list.push(instrument);
};
 
export const addNoiseInstrument = (song: Song, instrument: NoiseInstrument) => {
  const list = song.noise_instruments;
  instrument.index = list.length;
  list.push(instrument);
};