Skip to content

Commit

Permalink
update README with tracklist; bump package versions for dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
NumberOneBot committed Jan 11, 2025
1 parent bfafc3a commit 2cff083
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 32 deletions.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
# Demo Project of the DSSSP: React Library of Audio Processing and Visualization

For more details, see the original [repository](https://github.com/NumberOneBot/dsssp) of the DSSSP library.

## Tracklist

Tracks used for the demo:

- **BalloonPlanet** - _Cool My Bass_
- **Seth Parson** - _Waiting_
- **Gidon Schocken** - _I Owe It to You_
- **Adam Simons** - _Lost You_

Acquired from [Artlist.io](https://artlist.io) and should not be copied, distributed, or used for any commercial purposes.
12 changes: 6 additions & 6 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
},
"dependencies": {
"clsx": "^2.1.1",
"dsssp": "^0.1.9-alpha.2",
"dsssp": "^0.1.10-alpha.2",
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
Expand Down
23 changes: 0 additions & 23 deletions src/components/MusicPlayer/AudioController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,42 +30,35 @@ export class AudioController {
async init(url: string): Promise<void> {
try {
this.props.onLoadingChange(true)
console.log('Initializing AudioController...')

if (!this.audioContext) {
const AudioContextConstructor =
window.AudioContext || (window as any).webkitAudioContext
this.audioContext = new AudioContextConstructor()
console.log('AudioContext created.')

// Create AnalyserNodes
this.analyserLeft = this.audioContext.createAnalyser()
this.analyserRight = this.audioContext.createAnalyser()
this.analyserLeft.fftSize = 32
this.analyserRight.fftSize = 32
console.log('AnalyserNodes created.')

// Create ChannelSplitterNode
this.splitter = this.audioContext.createChannelSplitter(2)
console.log('ChannelSplitterNode created.')

// Connect analysers to splitter
if (this.splitter && this.analyserLeft && this.analyserRight) {
this.splitter.connect(this.analyserLeft, 0)
this.splitter.connect(this.analyserRight, 1)
console.log('AnalyserNodes connected to splitter.')

// **Connect splitter to destination**
this.splitter.connect(this.audioContext.destination)
console.log('Splitter connected to AudioContext.destination.')

// Emit analyser availability event
if (this.props.onAnalyserReady) {
this.props.onAnalyserReady({
left: this.analyserLeft,
right: this.analyserRight
})
console.log('onAnalyserReady event emitted.')
}
} else {
console.warn('Failed to initialize AnalyserNodes or splitter.')
Expand All @@ -74,7 +67,6 @@ export class AudioController {

// Load track
await this.loadTrack(url)
console.log('Track loaded.')

this.props.onLoadingChange(false)
} catch (error) {
Expand All @@ -99,7 +91,6 @@ export class AudioController {
await this.sourceNode.stop()
this.sourceNode.disconnect()
this.sourceNode = null
console.log('Existing sourceNode stopped and disconnected.')
} catch (error) {
console.warn('Error stopping existing source node:', error)
}
Expand All @@ -112,7 +103,6 @@ export class AudioController {
}
const arrayBuffer = await response.arrayBuffer()
this.audioBuffer = await this.audioContext.decodeAudioData(arrayBuffer)
console.log('Audio data decoded.')

// Update duration
this.props.onDurationChange(this.formatTime(this.audioBuffer.duration))
Expand Down Expand Up @@ -176,7 +166,6 @@ export class AudioController {
this.sourceNode.stop()
this.sourceNode.disconnect()
this.sourceNode = null
console.log('Existing sourceNode stopped and disconnected.')
} catch (error) {
console.warn('Error stopping existing source node:', error)
}
Expand All @@ -185,22 +174,18 @@ export class AudioController {
const sourceNode = this.audioContext.createBufferSource()
sourceNode.buffer = this.audioBuffer!
this.sourceNode = sourceNode
console.log('New sourceNode created.')

// Connect sourceNode to splitter
if (this.splitter) {
sourceNode.connect(this.splitter)
console.log('sourceNode connected to splitter.')
} else {
console.warn('ChannelSplitterNode is not initialized.')
// As a fallback, connect directly to destination
sourceNode.connect(this.audioContext.destination)
console.log('sourceNode connected directly to destination.')
}

try {
sourceNode.start(0, this.pausedAt)
console.log('sourceNode started.')
} catch (error) {
console.error('Error starting source node:', error)
return
Expand All @@ -223,15 +208,13 @@ export class AudioController {
this.sourceNode.stop()
this.sourceNode.disconnect()
this.sourceNode = null
console.log('sourceNode stopped and disconnected.')
} catch (error) {
console.warn('Error while stopping source node:', error)
}

if (this.requestAnimationFrameId != null) {
cancelAnimationFrame(this.requestAnimationFrameId)
this.requestAnimationFrameId = null
console.log('Animation frame canceled.')
}
}

Expand All @@ -246,7 +229,6 @@ export class AudioController {
this.sourceNode.stop()
this.sourceNode.disconnect()
this.sourceNode = null
console.log('sourceNode stopped and disconnected.')
} catch (error) {
console.warn('Error stopping source node:', error)
}
Expand All @@ -258,7 +240,6 @@ export class AudioController {
if (this.requestAnimationFrameId != null) {
cancelAnimationFrame(this.requestAnimationFrameId)
this.requestAnimationFrameId = null
console.log('Animation frame canceled.')
}
}

Expand All @@ -268,7 +249,6 @@ export class AudioController {
try {
this.sourceNode.stop()
this.sourceNode.disconnect()
console.log('sourceNode stopped and disconnected during cleanup.')
} catch (error) {
console.warn('Error stopping source node during cleanup:', error)
}
Expand All @@ -278,7 +258,6 @@ export class AudioController {
if (this.requestAnimationFrameId != null) {
cancelAnimationFrame(this.requestAnimationFrameId)
this.requestAnimationFrameId = null
console.log('Animation frame canceled during cleanup.')
}

// Close AudioContext
Expand All @@ -287,14 +266,12 @@ export class AudioController {
console.warn('Error closing AudioContext during cleanup:', error)
})
this.audioContext = null
console.log('AudioContext closed during cleanup.')
}

// Clear analysers and splitter
this.analyserLeft = null
this.analyserRight = null
this.splitter = null
console.log('AnalyserNodes and splitter cleared during cleanup.')
}

getAnalyserNodes() {
Expand Down
4 changes: 2 additions & 2 deletions src/components/MusicPlayer/CoversStack.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ export const CoversStack = ({
style={{
width: 34 - layer * 6,
height: 34 - layer * 6,
left: layer * -6,
left: layer * -5,
top: layer * 3,
filter: `brightness(${100 - layer * 30}%)`
filter: `brightness(${100 - layer * 25}%)`
}}
onClick={() => (layer === 0 ? onClick(index) : null)}
/>
Expand Down
7 changes: 7 additions & 0 deletions src/configs/tracks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,12 @@ export const tracks = [
'https://mqb-blog.com/sound/assets/896218_Gidon_Schocken_-_I_Owe_It_to_You_-_thumb.avif',
artist: 'Gidon Schocken',
title: 'I Owe It to You'
},
{
src: 'https://mqb-blog.com/sound/assets/Adam_North_Simons_-_One_Of_These_Days_-_BO-000184-5_-_Master_V1a_-_124_Bpm_-_210824_-_BOV_-_ORG_-_2444.aac',
cover:
'https://mqb-blog.com/sound/assets/948685_Adam_Simons_-_One_of_These_Days_-_A_-_Thum.avif',
artist: 'Adam Simons',
title: 'Lost You'
}
]

0 comments on commit 2cff083

Please sign in to comment.