mirror of
https://github.com/vale981/openAV-Luppp
synced 2025-03-05 17:11:40 -05:00
Another one
This commit is contained in:
parent
a8741927f8
commit
d3de3f0a0a
3 changed files with 13 additions and 17 deletions
|
@ -40,8 +40,6 @@ void AudioBuffer::init()
|
||||||
{
|
{
|
||||||
numBeats = 0;
|
numBeats = 0;
|
||||||
audioFrames = 0;
|
audioFrames = 0;
|
||||||
memset( name, 0, sizeof(char)*20 );
|
|
||||||
//sprintf( name, "%i", ID );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// this function is used for "resizing" an exisiting buffer, and should
|
/// this function is used for "resizing" an exisiting buffer, and should
|
||||||
|
@ -56,20 +54,18 @@ int AudioBuffer::getID()
|
||||||
return ID;
|
return ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudioBuffer::setName(const char* n)
|
void AudioBuffer::setName(const std::string& n)
|
||||||
{
|
{
|
||||||
memcpy( name, n, sizeof(char)* 19 );
|
name = n;
|
||||||
|
if (n.size() > 20) {
|
||||||
if ( strlen(n) > 19 ) {
|
|
||||||
#ifdef DEBUG_BUFFER
|
#ifdef DEBUG_BUFFER
|
||||||
cout << "AudioBuffer setName too long, truncating." << endl;
|
cout << "AudioBuffer setName too long, truncating." << endl;
|
||||||
#endif
|
#endif
|
||||||
return;
|
name.resize(20);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
char* AudioBuffer::getName()
|
const std::string& AudioBuffer::getName() const
|
||||||
{
|
{
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,9 +41,9 @@ public:
|
||||||
void setID(int id);
|
void setID(int id);
|
||||||
|
|
||||||
int getID();
|
int getID();
|
||||||
void setName(const char* n);
|
void setName(const std::string& n);
|
||||||
|
|
||||||
char* getName();
|
const std::string& getName() const;
|
||||||
int getBeats();
|
int getBeats();
|
||||||
|
|
||||||
void setBeats(int b);
|
void setBeats(int b);
|
||||||
|
@ -73,7 +73,7 @@ protected:
|
||||||
/// buffer.size(), which also has non-used space at the end.
|
/// buffer.size(), which also has non-used space at the end.
|
||||||
long audioFrames;
|
long audioFrames;
|
||||||
|
|
||||||
char name[20];
|
std::string name;
|
||||||
|
|
||||||
std::vector<float> bufferL;
|
std::vector<float> bufferL;
|
||||||
std::vector<float> bufferR;
|
std::vector<float> bufferR;
|
||||||
|
|
|
@ -262,8 +262,9 @@ int DiskReader::loadSample( int track, int scene, string path )
|
||||||
bool loadableBuffer = false;
|
bool loadableBuffer = false;
|
||||||
|
|
||||||
// retrieve sample metadata from sample.cfg using filename as key
|
// retrieve sample metadata from sample.cfg using filename as key
|
||||||
char* tmp = strdup( path.c_str() );
|
//char* tmp = strdup( path.c_str() );
|
||||||
char* baseName = basename( tmp );
|
std::string baseName = path.substr(path.find_last_of("/\\") + 1);
|
||||||
|
//char* baseName = basename( tmp );
|
||||||
//cout << "tmp " << tmp << " baseName " << baseName << endl;
|
//cout << "tmp " << tmp << " baseName " << baseName << endl;
|
||||||
ab->setName( baseName );
|
ab->setName( baseName );
|
||||||
|
|
||||||
|
@ -295,7 +296,7 @@ int DiskReader::loadSample( int track, int scene, string path )
|
||||||
return LUPPP_RETURN_ERROR;
|
return LUPPP_RETURN_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
cJSON* sample = cJSON_GetObjectItem( audioJson, baseName );
|
cJSON* sample = cJSON_GetObjectItem( audioJson, baseName.c_str() );
|
||||||
if ( sample ) {
|
if ( sample ) {
|
||||||
cJSON* beats = cJSON_GetObjectItem( sample, "beats" );
|
cJSON* beats = cJSON_GetObjectItem( sample, "beats" );
|
||||||
cJSON* name = cJSON_GetObjectItem( sample, "name" );
|
cJSON* name = cJSON_GetObjectItem( sample, "name" );
|
||||||
|
@ -325,7 +326,6 @@ int DiskReader::loadSample( int track, int scene, string path )
|
||||||
|
|
||||||
cJSON_Delete( audioJson );
|
cJSON_Delete( audioJson );
|
||||||
delete[] sampleString;
|
delete[] sampleString;
|
||||||
free ( tmp );
|
|
||||||
} else {
|
} else {
|
||||||
// this means there's no audio.cfg file found for the sample: show the user
|
// this means there's no audio.cfg file found for the sample: show the user
|
||||||
// the file, and ask what the intended beat number is, and load the AudioBuffer
|
// the file, and ask what the intended beat number is, and load the AudioBuffer
|
||||||
|
@ -340,7 +340,7 @@ int DiskReader::loadSample( int track, int scene, string path )
|
||||||
std::string sub = name.substr( i );
|
std::string sub = name.substr( i );
|
||||||
ab->setName( sub.c_str() );
|
ab->setName( sub.c_str() );
|
||||||
|
|
||||||
LUPPP_NOTE("AudioBuffer %s set %i beats", ab->getName(), ab->getBeats() );
|
LUPPP_NOTE("AudioBuffer %s set %i beats", ab->getName().c_str(), ab->getBeats() );
|
||||||
|
|
||||||
loadableBuffer = true;
|
loadableBuffer = true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue