Comments (4)
This would require some changes to the code:
- https://github.com/loov/jsfx/blob/master/jsfx.js#L7 change numChannels to 2.
- Before this https://github.com/loov/jsfx/blob/master/jsfx.js#L970, stride all data values with 0.
With regards to 2. point: M = Mono
, R = Right
, L = Left
. The data array contains all the samples [M, M, M, M ... ], stereo needs to have them in [L, R, L, R, L ... ]..., this means you need to convert the original data vector to [M, 0, M, 0 ...] or [0, M, 0, M ...], depending what you want.
Something like this should do:
var mono = data;
data = new createFloatArray(mono.length);
for(var i = 0; i < mono.length; i++){
data[i*2] = mono[i];
}
from jsfx.
Hi Egon,
Thank you. It works but sound was different a bit. It must be because data[i*2] exceeds the array length in half way through the for loop. So it assigns half of the full wave as a mono sound. So changed the for loop like this.
var mono = data;
data = new createFloatArray(mono.length);
for(var i = 0; i < mono.length; i+=2){
data[i] = mono[i];
}
from jsfx.
Nope, now the sound is two times shorter.... it should be data = new createFloatArray(mono.length * 2);
i.e.
var mono = data;
data = new createFloatArray(mono.length * 2);
for(var i = 0; i < mono.length; i++){
data[i*2] = mono[i];
}
Was tired yesterday, missed the multiplication.
from jsfx.
Ok. Thanks again.
from jsfx.
Related Issues (12)
- Mobile safari HOT 3
- Sound signal appears to be cut-off HOT 7
- CDN HOT 2
- How to get the raw data (WAV format) as a string to create a base64 dataURI? HOT 6
- Which files need to be hosted? HOT 10
- Figure out what to do about AudioContext and Chrome
- small noise on generated sounds HOT 6
- request: NPM package? HOT 1
- Callbacks / Custom events on audio ready? HOT 2
- Stop HOT 4
- jsmusic
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jsfx.