| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- """Original 104 BPM acoustic arrangement using licensed CC0 recorded instruments.
- No oscillator melody, electronic bass, kick, clap, hi-hat or pitch-sweep effects.
- Requires numpy, ffmpeg and the bundled SourceSamples~ directory.
- """
- from pathlib import Path
- import json, wave
- import numpy as np
- from acoustic_sampler import note, sample, SR
- ROOT=Path(__file__).resolve().parents[2]
- BPM=104
- BEAT=60/BPM
- FRAMES=round(64*BEAT*SR)
- mix=np.zeros((FRAMES,2),dtype=np.float64)
- rng=np.random.default_rng(11122026)
- def add(signal,beat,gain,pan=0,human=True):
- shift=rng.uniform(-.009,.009) if human else 0
- idx=(np.arange(len(signal))+round((beat*BEAT+shift)*SR))%FRAMES
- gain*=rng.uniform(.93,1.04)
- np.add.at(mix[:,0],idx,signal*gain*np.sqrt((1-pan)/2))
- np.add.at(mix[:,1],idx,signal*gain*np.sqrt((1+pan)/2))
- # Dmaj7 - Bm7 - Gmaj7 - A, a spacious plucked accompaniment to a wood-mallet melody.
- chords=[[50,57,62,66],[47,54,59,62],[43,50,55,59],[45,52,57,61],
- [43,50,55,59],[45,52,57,61],[50,57,62,66],[45,52,57,61]]*2
- roots=[38,35,31,33,31,33,38,33]*2
- melody=[
- [(.25,66,.65),(1.25,69,.6),(2,74,.8),(3.25,73,.55)],
- [(.25,71,.8),(1.5,69,.65),(2.5,66,.8)],
- [(.5,67,.65),(1.25,69,.55),(2,71,.9),(3.25,74,.55)],
- [(.25,73,.7),(1.5,69,.7),(2.75,64,.8)],
- [(.25,67,.7),(1.25,71,.6),(2.25,74,.9)],
- [(.5,73,.7),(1.5,71,.7),(2.5,69,.8)],
- [(.25,66,.6),(1,69,.6),(2,74,1.2)],
- [(.25,73,.65),(1.25,69,.65),(2.25,66,.65),(3.25,64,.5)],
- ]
- for bar in range(16):
- base=bar*4
- # Finger-plucked harp with quiet arpeggios, not a repeated electronic chord stab.
- for j,offset in enumerate([0,.55,1.05,1.55,2.1,2.65,3.05,3.55]):
- pitch=chords[bar][[0,2,1,3,0,2,1,3][j]]
- add(note('harp',pitch,1.15),base+offset,.077 if j%4 else .105,-.27)
- for offset,pitch,length in melody[bar%8]:
- # Second phrase answers with small melodic changes instead of an octave-bright layer.
- if bar>=8 and offset==2.25: pitch-=2
- add(note('marimba',pitch,max(.6,length*BEAT+.27)),base+offset,.21,.12)
- for offset,pitch in [(0,roots[bar]),(2.15,roots[bar]+7)]:
- add(note('bass',pitch,.82),base+offset,.13,0)
- # Light hand-played punctuation, no four-on-the-floor pulse.
- for offset in (1,3.08): add(sample('conga.wav',.22),base+offset,.033,-.12)
- for j,offset in enumerate([.55,1.55,2.55,3.55]):
- add(sample('shaker.wav',.12),base+offset,.013 if j%2 else .009,.3)
- if bar%4==3: add(sample('wood.wav',.1),base+3.65,.018,-.25)
- # Short natural room returns wrap across the seam, so the loop has no silent reset.
- dry=mix.copy()
- for delay,gain in [(.047,.055),(.083,.035),(.137,.018)]:
- mix+=np.roll(dry[:,::-1],round(delay*SR),axis=0)*gain
- mix-=np.mean(mix,axis=0)
- mix*=min(.79/np.max(abs(mix)),.115/np.sqrt(np.mean(mix**2)))
- # Match the seam over 2ms; no full-track fade or missing beat at the boundary.
- bridge=round(.002*SR)
- delta=mix[0]-mix[-1]
- mix[-bridge:]+=np.linspace(0,1,bridge)[:,None]*delta
- pcm=np.round(mix*32767).astype('<i2')
- with wave.open(str(ROOT/'Art/Audio/NeonDaydream.wav'),'wb') as f:
- f.setnchannels(2);f.setsampwidth(2);f.setframerate(SR);f.writeframes(pcm.tobytes())
- report=dict(title='Neon Daydream - Acoustic',bpm=BPM,key='D major',bars=16,seconds=FRAMES/SR,
- instruments=['recorded marimba','recorded harp','pizzicato contrabass','soft hand conga','shaker'],
- sampleRate=SR,channels=2,peakDbFS=float(20*np.log10(np.max(abs(mix)))),
- rmsDbFS=float(20*np.log10(np.sqrt(np.mean(mix**2)))),loopBoundaryDelta=float(np.max(abs(mix[0]-mix[-1]))),
- clippedSamples=int(np.sum(abs(pcm.astype(np.int32))>=32767)),
- source='Original arrangement rendered with VSCO CE CC0 samples; see AudioCredits.txt')
- (ROOT/'Art/Audio/NeonDaydream.json').write_text(json.dumps(report,indent=2)+'\n',encoding='utf-8')
- print(json.dumps(report,indent=2))
|