mirror of
https://github.com/vale981/openAV-Luppp
synced 2025-03-05 09:01:39 -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;
|
||||
audioFrames = 0;
|
||||
memset( name, 0, sizeof(char)*20 );
|
||||
//sprintf( name, "%i", ID );
|
||||
}
|
||||
|
||||
/// this function is used for "resizing" an exisiting buffer, and should
|
||||
|
@ -56,20 +54,18 @@ int AudioBuffer::getID()
|
|||
return ID;
|
||||
}
|
||||
|
||||
void AudioBuffer::setName(const char* n)
|
||||
void AudioBuffer::setName(const std::string& n)
|
||||
{
|
||||
memcpy( name, n, sizeof(char)* 19 );
|
||||
|
||||
if ( strlen(n) > 19 ) {
|
||||
name = n;
|
||||
if (n.size() > 20) {
|
||||
#ifdef DEBUG_BUFFER
|
||||
cout << "AudioBuffer setName too long, truncating." << endl;
|
||||
#endif
|
||||
return;
|
||||
name.resize(20);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
char* AudioBuffer::getName()
|
||||
const std::string& AudioBuffer::getName() const
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
|
|
@ -41,9 +41,9 @@ public:
|
|||
void setID(int id);
|
||||
|
||||
int getID();
|
||||
void setName(const char* n);
|
||||
void setName(const std::string& n);
|
||||
|
||||
char* getName();
|
||||
const std::string& getName() const;
|
||||
int getBeats();
|
||||
|
||||
void setBeats(int b);
|
||||
|
@ -73,7 +73,7 @@ protected:
|
|||
/// buffer.size(), which also has non-used space at the end.
|
||||
long audioFrames;
|
||||
|
||||
char name[20];
|
||||
std::string name;
|
||||
|
||||
std::vector<float> bufferL;
|
||||
std::vector<float> bufferR;
|
||||
|
|
|
@ -262,8 +262,9 @@ int DiskReader::loadSample( int track, int scene, string path )
|
|||
bool loadableBuffer = false;
|
||||
|
||||
// retrieve sample metadata from sample.cfg using filename as key
|
||||
char* tmp = strdup( path.c_str() );
|
||||
char* baseName = basename( tmp );
|
||||
//char* tmp = strdup( path.c_str() );
|
||||
std::string baseName = path.substr(path.find_last_of("/\\") + 1);
|
||||
//char* baseName = basename( tmp );
|
||||
//cout << "tmp " << tmp << " baseName " << baseName << endl;
|
||||
ab->setName( baseName );
|
||||
|
||||
|
@ -295,7 +296,7 @@ int DiskReader::loadSample( int track, int scene, string path )
|
|||
return LUPPP_RETURN_ERROR;
|
||||
}
|
||||
|
||||
cJSON* sample = cJSON_GetObjectItem( audioJson, baseName );
|
||||
cJSON* sample = cJSON_GetObjectItem( audioJson, baseName.c_str() );
|
||||
if ( sample ) {
|
||||
cJSON* beats = cJSON_GetObjectItem( sample, "beats" );
|
||||
cJSON* name = cJSON_GetObjectItem( sample, "name" );
|
||||
|
@ -325,7 +326,6 @@ int DiskReader::loadSample( int track, int scene, string path )
|
|||
|
||||
cJSON_Delete( audioJson );
|
||||
delete[] sampleString;
|
||||
free ( tmp );
|
||||
} else {
|
||||
// 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
|
||||
|
@ -340,7 +340,7 @@ int DiskReader::loadSample( int track, int scene, string path )
|
|||
std::string sub = name.substr( i );
|
||||
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;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue