mirror of
https://github.com/captbaritone/webamp.git
synced 2026-07-31 22:14:09 +00:00
Create preamp
This commit is contained in:
parent
54115f2879
commit
1c175ae0a3
2 changed files with 20 additions and 14 deletions
21
js/media.js
21
js/media.js
|
|
@ -24,6 +24,9 @@ module.exports = {
|
|||
// The _source node has to be recreated each time it's stopped or
|
||||
// paused, so we don't create it here.
|
||||
|
||||
// Create the preamp node
|
||||
this._preamp = this._context.createGain();
|
||||
|
||||
// Create the spliter node
|
||||
this._chanSplit = this._context.createChannelSplitter(2);
|
||||
|
||||
|
|
@ -64,6 +67,8 @@ module.exports = {
|
|||
// |
|
||||
// destination
|
||||
|
||||
this._preamp.connect(this._chanSplit);
|
||||
|
||||
// Connect split channels to left / right gains
|
||||
this._chanSplit.connect(this._leftGain, 0);
|
||||
this._chanSplit.connect(this._rightGain, 1);
|
||||
|
|
@ -160,7 +165,7 @@ module.exports = {
|
|||
this._source = this._context.createBufferSource();
|
||||
this._source.buffer = this._buffer;
|
||||
this._source.connect(this._analyser);
|
||||
this._source.connect(this._chanSplit);
|
||||
this._source.connect(this._preamp);
|
||||
|
||||
this._position = typeof position !== 'undefined' ? position : this._position;
|
||||
this._startTime = this._context.currentTime - this._position;
|
||||
|
|
@ -201,8 +206,10 @@ module.exports = {
|
|||
this._gainNode.gain.value = volume / 100;
|
||||
},
|
||||
|
||||
getVolume: function() {
|
||||
return this._gainNode.gain.value * 100;
|
||||
// From 0-1
|
||||
setPreamp: function(value) {
|
||||
console.log('preamp', value);
|
||||
this._preamp.gain.value = value / 100;
|
||||
},
|
||||
|
||||
// From -100 to 100
|
||||
|
|
@ -231,14 +238,6 @@ module.exports = {
|
|||
this.bands[band].gain.value = db;
|
||||
},
|
||||
|
||||
setPreamp: function() {
|
||||
// ??
|
||||
},
|
||||
|
||||
getBalance: function() {
|
||||
return this._balance;
|
||||
},
|
||||
|
||||
toggleRepeat: function() {
|
||||
this._loop = !this._loop;
|
||||
},
|
||||
|
|
|
|||
13
js/winamp.js
13
js/winamp.js
|
|
@ -1,7 +1,13 @@
|
|||
// UI and App logic
|
||||
import Media from './media';
|
||||
import MyFile from './myFile';
|
||||
import {setSkinFromUrl, setSkinFromFile} from './actionCreators';
|
||||
import {
|
||||
setSkinFromUrl,
|
||||
setSkinFromFile,
|
||||
setVolume,
|
||||
setPreamp,
|
||||
setBalance
|
||||
} from './actionCreators';
|
||||
|
||||
import '../css/winamp.css';
|
||||
|
||||
|
|
@ -12,8 +18,9 @@ module.exports = {
|
|||
this.fileInput.type = 'file';
|
||||
this.fileInput.style.display = 'none';
|
||||
|
||||
this.dispatch({type: 'SET_VOLUME', volume: options.volume});
|
||||
this.dispatch({type: 'SET_BALANCE', balance: options.balance});
|
||||
this.dispatch(setVolume(this.media, options.volume));
|
||||
this.dispatch(setBalance(this.media, options.balance));
|
||||
this.dispatch(setPreamp(this.media, 50));
|
||||
this.loadFromUrl(options.mediaFile.url, options.mediaFile.name);
|
||||
this.dispatch(setSkinFromUrl(options.skinUrl));
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue