Example #1
0
TEST_F(testsDataChunk, DefaultConstructor) {
    DataChunk empty;
    EXPECT_TRUE(empty.isReferencing(NULL));
    EXPECT_TRUE(empty.getData() == NULL);
    EXPECT_TRUE(empty.getSize() == 0);
    DataChunk emptyRef;
    emptyRef.reference(empty);
    EXPECT_TRUE(emptyRef.isReferencing(NULL));
    EXPECT_TRUE(emptyRef.getData() == NULL);
    EXPECT_TRUE(emptyRef.getSize() == 0);
    EXPECT_TRUE(emptyRef == empty);
}
void DiskreteEffect::apply(DataChunk &samples){
    unsigned short bytePerSample=samples.getFormat()->bitsPerSample()/8;
    unsigned int count=samples.getSize()/bytePerSample; //samples count
    char *data8 = samples.getData();
    short *data16 = (short*)data8;

    switch (bytePerSample) {
        case 1:
            maxint=127;
            for(unsigned int i=0;i<count;i++)
                data8[i]=apply(data8[i]-0x80)+0x80;
            break;
        case 2:
            maxint=32767;
            for(unsigned int i=0;i<count;i++)
                data16[i]=apply(data16[i]);
            break;
        default:
            throw "Такой битрейт пока не поддерживается";
    }
}