GUI: sample editor keybinds
works
This commit is contained in:
parent
f4f91ca49e
commit
705ba4273b
9 changed files with 629 additions and 208 deletions
|
|
@ -258,6 +258,42 @@ bool DivSample::trim(unsigned int begin, unsigned int end) {
|
|||
return false;
|
||||
}
|
||||
|
||||
// TODO: for clipboard
|
||||
bool DivSample::insert(unsigned int pos, unsigned int length) {
|
||||
unsigned int count=samples+length;
|
||||
if (depth==8) {
|
||||
if (data8!=NULL) {
|
||||
signed char* oldData8=data8;
|
||||
data8=NULL;
|
||||
initInternal(8,count);
|
||||
if (pos>0) {
|
||||
memcpy(data8,oldData8,pos);
|
||||
}
|
||||
if (count-pos-length>0) {
|
||||
memcpy(data8+pos+length,oldData8+pos,count-pos-length);
|
||||
}
|
||||
delete[] oldData8;
|
||||
} else {
|
||||
initInternal(8,count);
|
||||
}
|
||||
samples=count;
|
||||
return true;
|
||||
} else if (depth==16) {
|
||||
if (data16!=NULL) {
|
||||
short* oldData16=data16;
|
||||
data16=NULL;
|
||||
initInternal(16,count);
|
||||
memcpy(data16,oldData16,sizeof(short)*count);
|
||||
delete[] oldData16;
|
||||
} else {
|
||||
initInternal(16,count);
|
||||
}
|
||||
samples=count;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
#define RESAMPLE_BEGIN \
|
||||
if (samples<1) return true; \
|
||||
int finalCount=(double)samples*(r/(double)rate); \
|
||||
|
|
|
|||
|
|
@ -120,6 +120,15 @@ struct DivSample {
|
|||
*/
|
||||
bool trim(unsigned int begin, unsigned int end);
|
||||
|
||||
/**
|
||||
* insert silence at specified position.
|
||||
* @warning do not attempt to do this outside of a synchronized block!
|
||||
* @param pos the beginning.
|
||||
* @param length how many samples to insert.
|
||||
* @return whether it was successful.
|
||||
*/
|
||||
bool insert(unsigned int pos, unsigned int length);
|
||||
|
||||
/**
|
||||
* change the sample rate.
|
||||
* @warning do not attempt to resample outside of a synchronized block!
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue