Skip to content

Commit b259e31

Browse files
committed
Added different musical scale
1 parent 0f0c36c commit b259e31

File tree

3 files changed

+36
-14
lines changed

3 files changed

+36
-14
lines changed

src/components/GitSequencer.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ const GitSequencer = () => {
4444

4545
// Custom hooks for audio
4646
const audioEngine = useAudioEngine(username, volumes, data);
47-
const sequencer = useSequencer(audioEngine);
47+
const sequencer = useSequencer(audioEngine, username);
4848

4949
const {
5050
isPlaying,

src/hooks/useAudioEngine.js

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,28 @@ import * as Tone from 'tone';
33

44
const SCALES = {
55
pentatonic: ['C4', 'D4', 'E4', 'G4', 'A4', 'C5', 'D5'],
6-
lydian: ['C4', 'D4', 'E4', 'F#4', 'G4', 'A4', 'B4'],
7-
dorian: ['C4', 'D4', 'Eb4', 'F4', 'G4', 'A4', 'Bb4'],
8-
phrygianDom: ['C4', 'Db4', 'E4', 'F4', 'G4', 'Ab4', 'Bb4']
6+
// Lydian: Bright/Dreamy. Removed the 7th(B) in low oct to avoid clutter, kept the #4(F#) for flavor.
7+
lydian: ['C4', 'E4', 'F#4', 'G4', 'A4', 'C5', 'E5'],
8+
// Dorian: Soulful/Jazzy. Removed the 2nd(D) to focus on the minor 3rd and major 6th.
9+
dorian: ['C4', 'Eb4', 'F4', 'G4', 'A4', 'Bb4', 'C5'],
10+
// Phrygian Dom: Exotic. Removed b2(Db) and b6(Ab) from melody to prevent harsh clashes.
11+
phrygianDom: ['C4', 'E4', 'F4', 'G4', 'Bb4', 'C5', 'E5'],
12+
// Mixolydian: Uplifting/Psychedelic (Jerry Garcia style). Major 3rd + Flat 7.
13+
mixolydian: ['C4', 'E4', 'G4', 'A4', 'Bb4', 'C5', 'D5'],
14+
// Harmonic Minor: Neoclassical/Dramatic. Spooky vibe with the raised 7th (B).
15+
harmonicMinor: ['C4', 'Eb4', 'G4', 'Ab4', 'B4', 'C5', 'Eb5'],
16+
// Hirajoshi: Japanese Pentatonic. Dark, ambient, and introspective.
17+
hirajoshi: ['C4', 'Db4', 'F4', 'G4', 'Ab4', 'C5', 'Db5']
918
};
1019

1120
const CHORD_ROOTS = {
1221
pentatonic: ['C3', 'D3', 'E3', 'G3', 'A3', 'C4', 'D4'],
13-
lydian: ['C3', 'D3', 'E3', 'F#3', 'G3', 'A3', 'B3'],
14-
dorian: ['C3', 'D3', 'Eb3', 'F3', 'G3', 'A3', 'Bb3'],
15-
phrygianDom: ['C3', 'Db3', 'E3', 'F3', 'G3', 'Ab3', 'Bb3']
22+
lydian: ['C3', 'E3', 'G3', 'A3', 'C4', 'E4', 'F#4'],
23+
dorian: ['C3', 'Eb3', 'G3', 'A3', 'Bb3', 'C4', 'F4'],
24+
phrygianDom: ['C3', 'E3', 'G3', 'Bb3', 'C4', 'E4', 'F4'],
25+
mixolydian: ['C3', 'E3', 'G3', 'A3', 'Bb3', 'C4', 'D4'],
26+
harmonicMinor: ['C3', 'Eb3', 'G3', 'Ab3', 'B3', 'C4', 'Eb4'],
27+
hirajoshi: ['C3', 'Db3', 'F3', 'G3', 'Ab3', 'C4', 'Db4']
1628
};
1729

1830
const VELOCITIES = [0, 0.5, 0.6, 0.7, 0.8];

src/hooks/useSequencer.js

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,37 @@
11
import { useState, useRef, useCallback } from 'react';
22
import * as Tone from 'tone';
33

4-
export function useSequencer(audioEngine) {
4+
// Helper to get signature scale based on username hash
5+
// Helper to get a random scale from the safe list
6+
const getRandomScale = () => {
7+
const SCALES = ['pentatonic', 'lydian', 'dorian', 'phrygianDom', 'mixolydian', 'harmonicMinor', 'hirajoshi'];
8+
return SCALES[Math.floor(Math.random() * SCALES.length)];
9+
};
10+
11+
export function useSequencer(audioEngine, username) {
512
const [isPlaying, setIsPlaying] = useState(false);
613
const [activeCol, setActiveCol] = useState(-1);
714
const [activeNotes, setActiveNotes] = useState([]);
8-
const [scaleType, setScaleType] = useState('pentatonic');
15+
16+
// Initial scale is random for every session/refresh
17+
const signatureScaleRef = useRef(getRandomScale());
18+
const signatureScale = signatureScaleRef.current;
19+
20+
const [scaleType, setScaleType] = useState(signatureScale);
921
const [currentPattern, setCurrentPattern] = useState('Zen');
1022
const [bpm, setBpm] = useState(80);
1123
const [autoScale, setAutoScale] = useState(true);
1224

13-
const scaleTypeRef = useRef('pentatonic');
25+
const scaleTypeRef = useRef(signatureScale);
1426
const autoScaleRef = useRef(true);
1527
const sequenceRef = useRef(null);
1628

1729
const { playNote, playChord, playKick, playSnare, playHiHat } = audioEngine;
1830

1931
// Determine scale based on activity level
32+
// FIXED: Use Single Signature Scale for consistent musical journey per user
2033
const getScaleForActivity = (activity) => {
21-
if (activity > 50) return { scale: 'phrygianDom', pattern: 'Intense (Extreme)' };
22-
if (activity > 30) return { scale: 'dorian', pattern: 'Focus (High)' };
23-
if (activity > 10) return { scale: 'lydian', pattern: 'Dreamy (Med)' };
24-
return { scale: 'pentatonic', pattern: 'Zen (Low)' };
34+
return { scale: scaleTypeRef.current, pattern: 'Flow' };
2535
};
2636

2737
// Calculate block activity (sum of levels in a 4-week block)

0 commit comments

Comments
 (0)