mirror of
https://github.com/overte-org/overte.git
synced 2025-04-26 01:36:20 +02:00
31 lines
No EOL
679 B
C++
31 lines
No EOL
679 B
C++
//
|
|
// AudioSource.cpp
|
|
// interface
|
|
//
|
|
// Created by Stephen Birarda on 1/29/13.
|
|
// Copyright (c) 2013 HighFidelity, Inc. All rights reserved.
|
|
//
|
|
|
|
#include "AudioSource.h"
|
|
|
|
AudioSource::~AudioSource()
|
|
{
|
|
delete[] sourceData;
|
|
}
|
|
|
|
|
|
int AudioSource::loadDataFromFile(const char *filename) {
|
|
FILE *soundFile = fopen(filename, "r");
|
|
|
|
// get length of file:
|
|
std::fseek(soundFile, 0, SEEK_END);
|
|
lengthInSamples = std::ftell(soundFile) / sizeof(int16_t);
|
|
std::rewind(soundFile);
|
|
|
|
sourceData = new int16_t[lengthInSamples];
|
|
std::fread(sourceData, sizeof(int16_t), lengthInSamples, soundFile);
|
|
|
|
std::fclose(soundFile);
|
|
|
|
return 0;
|
|
} |