Merge pull request from PhilipRosedale/master

Procedural noise support added on client, adds a bit of noise when moving
This commit is contained in:
ZappoMan 2013-05-08 17:44:15 -07:00
commit bf81587e1b
7 changed files with 54 additions and 3 deletions

View file

@ -111,7 +111,8 @@ int audioCallback (const void *inputBuffer,
int16_t *inputLeft = ((int16_t **) inputBuffer)[0];
// printLog("Audio callback at %6.0f\n", usecTimestampNow()/1000);
// Add Procedural effects to input samples
data->addProceduralSounds(inputLeft, BUFFER_LENGTH_SAMPLES);
if (inputLeft != NULL) {

View file

@ -30,6 +30,9 @@ public:
void setWalkingState(bool newWalkState);
void setLastAcceleration(glm::vec3 a) { audioData->setLastAcceleration(a); };
void setLastVelocity(glm::vec3 v) { audioData->setLastVelocity(v); };
// terminates audio I/O
bool terminate();
private:

View file

@ -28,4 +28,20 @@ AudioData::~AudioData() {
delete audioSocket;
}
// Take a pointer to the acquired microphone input samples and add procedural sounds
void AudioData::addProceduralSounds(int16_t* inputBuffer, int numSamples) {
const float MAX_AUDIBLE_VELOCITY = 3.0;
const float MIN_AUDIBLE_VELOCITY = 0.1;
const float VOLUME = 200;
float speed = glm::length(_lastVelocity);
if ((speed > MIN_AUDIBLE_VELOCITY) && (speed < MAX_AUDIBLE_VELOCITY)) {
for (int i = 0; i < numSamples; i++) {
inputBuffer[i] += (int16_t) ((randFloat() - 0.5f) * VOLUME * speed) ;
}
}
return;
}
#endif

View file

@ -39,6 +39,17 @@ class AudioData {
bool mixerLoopbackFlag;
bool playWalkSound;
// Added avatar acceleration and velocity for procedural effects sounds from client
void setLastVelocity(glm::vec3 v) { _lastVelocity = v; };
void setLastAcceleration(glm::vec3 a) { _lastAcceleration = a; };
void addProceduralSounds(int16_t* inputBuffer, int numSamples);
private:
glm::vec3 _lastVelocity;
glm::vec3 _lastAcceleration;
};
#endif /* defined(__interface__AudioData__) */

View file

@ -105,6 +105,7 @@ public:
const glm::vec3& getJointPosition(AvatarJointID j) const { return _joint[j].position; };
const glm::vec3& getBodyUpDirection() const { return _orientation.getUp(); };
float getSpeed() const { return _speed; };
const glm::vec3& getVelocity() const { return _velocity; };
float getGirth();
float getHeight();

View file

@ -1695,6 +1695,7 @@ void idle(void) {
handControl.stop();
}
// Read serial port interface devices
if (serialPort.active && USING_INVENSENSE_MPU9150) {
serialPort.readData();
}
@ -1720,7 +1721,11 @@ void idle(void) {
myAvatar.setGravity(getGravity(myAvatar.getPosition()));
myAvatar.simulate(deltaTime);
// Update audio stats for procedural sounds
audio.setLastAcceleration(myAvatar.getThrust());
audio.setLastVelocity(myAvatar.getVelocity());
glutPostRedisplay();
lastTimeIdle = check;
}

View file

@ -12,7 +12,21 @@
VoxelTree myTree;
void voxelTutorial(VoxelTree* tree) {
int _nodeCount=0;
bool countVoxelsOperation(VoxelNode* node, void* extraData) {
if (node->isColored()){
_nodeCount++;
}
return true; // keep going
}
void addLandscape(VoxelTree * tree) {
printf("Adding Landscape...\n");
}
void addScene(VoxelTree * tree) {
printf("adding scene...\n");
// We want our corner voxels to be about 1/2 meter high, and our TREE_SCALE is in meters, so...
float voxelSize = 0.5f / TREE_SCALE;