Skip to content

Commit

Permalink
DAW#85 Fix Transport.stop() & Refactoring & Sampler & Bass basics
Browse files Browse the repository at this point in the history
  • Loading branch information
artiphishle committed Oct 26, 2023
1 parent 94f19c8 commit fd41a6f
Show file tree
Hide file tree
Showing 22 changed files with 479 additions and 396 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,16 @@ Design will be applied soon, this is just a raw sketch!

### 🍂 October 2023

#### October, 25th

<div class="flex">
<img width="133" alt="Screenshot 2023-10-25 at 05 35 02" src="https://github.com/artiphishle/daw/assets/137318798/de1cd173-3d98-49b9-b284-b080a7263c4f">

**Nice Gold Knob**<br>
(Design by *ykadosh*)

</div>

#### October, 24th

- **Arranger** Track selection (active track)
Expand Down
3 changes: 2 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

43 changes: 24 additions & 19 deletions src/app/api/(routes)/project/presets/DefaultPreset.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,32 @@
import {
/*** @project */
DEFAULT_ACTIVE_TRACK_ID,
DEFAULT_STATES,
DEFAULT_BPM,
DEFAULT_CLEF,
DEFAULT_MEASURE_COUNT,
DEFAULT_NAME,
DEFAULT_POSITION,
DEFAULT_QUANTIZATION,
DEFAULT_SCALE,
DEFAULT_SWING,
DEFAULT_SWING_SUBDIVISION,

/*** @track */
DEFAULT_TRACK_SAMPLER,
DEFAULT_TRACK_INSTRUMENT_BASS,
// DEFAULT_TRACK_AUDIO,
// DEFAULT_TRACK_SAMPLER,
// DEFAULT_TRACK_PLAYERS,
// DEFAULT_TRACK_HI_TOM,
// DEFAULT_TRACK_MI_TOM,
// DEFAULT_TRACK_LO_TOM,
// DEFAULT_TRACK_BD,
// DEFAULT_TRACK_SD,
// DEFAULT_TRACK_OH,

/*** @tchannel */
DEFAULT_CHANNEL_DRUMS,
DEFAULT_CHANNEL_MASTER,
DEFAULT_TRACK_HI_TOM,
DEFAULT_TRACK_MI_TOM,
DEFAULT_TRACK_LO_TOM,
DEFAULT_TRACK_BD,
DEFAULT_TRACK_SD,
DEFAULT_SCALE,
DEFAULT_ACTIVE_TRACK_ID,
DEFAULT_TRACK_OH,
DEFAULT_SWING,
DEFAULT_SWING_SUBDIVISION,
} from '@/constants';

import type { IProjectContext } from '@/types/project.types';
Expand All @@ -40,14 +45,14 @@ const DefaultPreset: IProjectContext = {
swing: DEFAULT_SWING,
swingSubdivision: DEFAULT_SWING_SUBDIVISION,
tracks: [
DEFAULT_TRACK_BD,
DEFAULT_TRACK_SD,
DEFAULT_TRACK_OH,
DEFAULT_TRACK_HI_TOM,
DEFAULT_TRACK_MI_TOM,
DEFAULT_TRACK_LO_TOM,
// DEFAULT_TRACK_INSTRUMENT_BASS,
// DEFAULT_TRACK_SAMPLER,
DEFAULT_TRACK_SAMPLER,
DEFAULT_TRACK_INSTRUMENT_BASS,
// DEFAULT_TRACK_BD,
// DEFAULT_TRACK_SD,
// DEFAULT_TRACK_OH,
// DEFAULT_TRACK_HI_TOM,
// DEFAULT_TRACK_MI_TOM,
// DEFAULT_TRACK_LO_TOM,
// DEFAULT_TRACK_AUDIO,
// DEFAULT_TRACK_PLAYERS,
],
Expand Down
137 changes: 83 additions & 54 deletions src/app/common/constants.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import _ from 'lodash/fp';
import * as Tone from 'tone';

import t from '@/core/i18n';

Expand All @@ -7,7 +8,7 @@ import type { IChannel } from './types/channel.types';
import { EInstrument } from './types/instrument.types';

// ---------- General
/*** @Progression */
/*** @constants */
export const PROGRESSION = [
/*** @Diatonic */
// Major
Expand Down Expand Up @@ -41,13 +42,19 @@ export const PROGRESSION = [
// Montgomery Ward bridge
'I IV ii V',
];
export const ROMAN_NUMS = ['i', 'ii', 'iii', 'iv', 'v', 'vi', 'vii'];

export const isRomanNum = (test: string) =>
['i', 'ii', 'iii', 'iv', 'v', 'vi', 'vii'].includes(test.toLowerCase());
// ---------- Utils
/*** @utils */
export const getMeasureTime = (n: number) => Tone.Time(`${n}m`);
export const getMeasureSeconds = (n: number) => getMeasureTime(n).toSeconds();
export const getNotationTime = (n: number) => Tone.Time(`${n}n`);
export const getNotationSeconds = (n: number) => getNotationTime(n).toSeconds();
export const isRomanNum = (s: string) => ROMAN_NUMS.includes(_.toLower(s));

// ---------- Project
const DEFAULT_ACTIVE_TRACK_ID = 'track-bd';
const DEFAULT_BPM = 98;
const DEFAULT_BPM = 120;
const DEFAULT_CLEF = 'D';
const DEFAULT_SCALE = 'minor';
const DEFAULT_MEASURE_COUNT = 2;
Expand All @@ -72,24 +79,24 @@ const DEFAULT_TRACK_INSTRUMENT_BASS: ITrack = {
output: 'master',
input: {
id: EInstrument.MonoSynth,
label: 'BA',
label: 'in-bass',
options: {
oscillator: { type: 'sawtooth' },
envelope: { attack: 0.01, decay: 0.4, release: 0.3, sustain: 0.2 },
filterEnvelope: {
attack: 0.001,
baseFrequency: 180,
decay: 0.2,
octaves: 0,
octaves: 2,
release: 0.2,
sustain: 0.25,
},
volume: -35,
volume: -31,
},
parts: [
{
label: 'BA-Part1',
events: [],
label: 'p1-bass',
notes: [['D1'], ['D1'], ['D1'], ['D1'], ['F#1'], ['F#1'], [], []],
},
],
},
Expand Down Expand Up @@ -129,11 +136,11 @@ const DEFAULT_TRACK_BD: ITrack = {
parts: [
{
label: 'BD',
events: [{ note: 'C2', duration: '16n', x: 0 }],
times: [0],
},
{
label: 'BD',
events: [{ note: 'C2', duration: '16n', x: 0 }],
times: [0],
},
],
},
Expand All @@ -155,11 +162,11 @@ const DEFAULT_TRACK_SD: ITrack = {
parts: [
{
label: 'p1-SD',
events: [{ note: 'D2', duration: '16n', x: 8 }],
times: [8],
},
{
label: 'p2-SD',
events: [{ note: 'D2', duration: '16n', x: 8 }],
times: [8],
},
],
},
Expand All @@ -181,27 +188,11 @@ const DEFAULT_TRACK_OH: ITrack = {
parts: [
{
label: 'p1-oh',
events: [
{ note: 'F#2', duration: '16n', x: 0 },
{ note: 'F#2', duration: '16n', x: 2 },
{ note: 'F#2', duration: '16n', x: 4 },
{ note: 'F#2', duration: '16n', x: 6 },
{ note: 'F#2', duration: '16n', x: 8 },
{ note: 'F#2', duration: '16n', x: 10 },
{ note: 'F#2', duration: '16n', x: 12 },
{ note: 'F#2', duration: '16n', x: 14 },
],
times: [0, 2, 4, 6, 8, 10, 12, 14],
},
{
label: 'p2-oh',
events: [
{ note: 'F#2', duration: '16n', x: 0 },
{ note: 'F#2', duration: '16n', x: 2 },
{ note: 'F#2', duration: '16n', x: 4 },
{ note: 'F#2', duration: '16n', x: 6 },
{ note: 'F#2', duration: '16n', x: 8 },
{ note: 'F#2', duration: '16n', x: 10 },
],
times: [0, 2, 4, 6, 8, 10],
},
],
},
Expand All @@ -221,13 +212,10 @@ const DEFAULT_TRACK_HI_TOM: ITrack = {
url: './samples/WaveAlchemy/wa_drm_drums/high_tom/wadrm_hitom_acc1_r2.wav',
},
parts: [
{ label: 'HiTomPart1', events: [] },
{ label: 'HiTomPart1', times: [] },
{
label: 'HiTomPart2',
events: [
{ note: 'C4', duration: '16n', x: 12 },
{ note: 'C4', duration: '16n', x: 13 },
],
times: [12, 13],
},
],
},
Expand All @@ -249,11 +237,11 @@ const DEFAULT_TRACK_MI_TOM: ITrack = {
parts: [
{
label: 'MiTomPart',
events: [],
times: [],
},
{
label: 'MiTomPart',
events: [{ note: 'F4', duration: '16n', x: 14 }],
times: [14],
},
],
},
Expand All @@ -275,11 +263,11 @@ const DEFAULT_TRACK_LO_TOM: ITrack = {
parts: [
{
label: 'LoTomPart',
events: [],
times: [],
},
{
label: 'LoTomPart',
events: [{ note: 'E4', duration: '16n', x: 15 }],
times: [15],
},
],
},
Expand All @@ -290,12 +278,12 @@ const DEFAULT_TRACK_LO_TOM: ITrack = {
// -------- Sampler
/*** @Track */
const DEFAULT_TRACK_SAMPLER: ITrack = {
id: 'track-sampler',
name: 'Sampler',
id: 'sampler-drums',
name: 'Drums',
routing: {
input: {
id: EInstrument.Sampler,
label: 'Drums',
label: 'in-drums',
options: {
baseUrl: './samples/WaveAlchemy/wa_808_tape/',
urls: {
Expand All @@ -304,13 +292,54 @@ const DEFAULT_TRACK_SAMPLER: ITrack = {
E3: 'wa_808tape_closedhat_08_clean.wav',
},
volume: -40,
fadeIn: 0.2,
fadeOut: 0.2,
fadeIn: 0.01,
fadeOut: 0.01,
curve: 'linear',
},
parts: [
{
label: 'Drums (Sampler)',
events: [],
label: 'p1-sampler',
notes: [
['C3', 'E3'],
['E3'],
[],
['C3', 'E3'],
['D3'],
['E3'],
['C3', 'E3'],
['E3'],
['C3', 'E3'],
['C3', 'E3'],
[],
['E3'],
['D3', 'E3'],
[],
[],
['E3'],
],
},
{
label: 'p2-sampler',
notes: [
['C3', 'E3'],
['E3'],
[],
['C3', 'E3'],
['D3'],
[],
['C3', 'E3'],
['E3'],
['C3', 'E3'],
['C3', 'E3'],
[],
['E3'],
['D3', 'E3'],
[],
['E3'],
[],
[],
[],
],
},
],
},
Expand Down Expand Up @@ -365,16 +394,16 @@ export {
//
DEFAULT_STATES,
//
DEFAULT_TRACK_SAMPLER,
// DEFAULT_TRACK_AUDIO,
DEFAULT_TRACK_INSTRUMENT_BASS,
// DEFAULT_TRACK_PLAYERS,
// DEFAULT_TRACK_SAMPLER,
DEFAULT_TRACK_BD,
DEFAULT_TRACK_SD,
DEFAULT_TRACK_OH,
DEFAULT_TRACK_HI_TOM,
DEFAULT_TRACK_MI_TOM,
DEFAULT_TRACK_LO_TOM,
// DEFAULT_TRACK_BD,
// DEFAULT_TRACK_SD,
// DEFAULT_TRACK_OH,
// DEFAULT_TRACK_HI_TOM,
// DEFAULT_TRACK_MI_TOM,
// DEFAULT_TRACK_LO_TOM,
DEFAULT_CHANNEL_DRUMS,
DEFAULT_CHANNEL_MASTER,
};
4 changes: 4 additions & 0 deletions src/app/common/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ const styles = {
meter: 'w-full bg-[#333]',
track: {
main: 'pt-6 bg-[#3e4140] border border-r-[#555] border-r-[2px] justify-center text-xs items-center content-end',
channel: 'justify-end relative bg-green-700',
inner: 'flex px-4 items-center gap-1 py-2 border-b border-b-[#555]',
master:
'bg-[#3e4140] border border-r-[#555] border-r-[2px] h-full flex flex-col justify-end',
Expand All @@ -50,6 +51,9 @@ const styles = {
bg: 'bg-transparent',
bgActive: 'bg-blue-900 text-white',
},
time: {
main: 'flex flex-1 items-center px-1 py-2 border-l border-r-gray-200',
},
track: {
audio: { main: 'w-full flex flex-col justify-center' },
time: 'flex w-full bg-white text-gray-500 text-xs',
Expand Down
Loading

0 comments on commit fd41a6f

Please sign in to comment.