예제 #1
0
파일: C700.cpp 프로젝트: justcfx2u/C700
//-----------------------------------------------------------------------------
int C700::CreatePGDataDic(CFDictionaryRef *data, int pgnum)
{
    CFMutableDictionaryRef dict = CFDictionaryCreateMutable	(NULL, 0,
                                  &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
    const InstParams	*vpSet = mEfx->GetVP();

    if (vpSet[pgnum].loop) {
        vpSet[pgnum].brr.data[vpSet[pgnum].brr.size - 9] |= 2;
    }
    else {
        vpSet[pgnum].brr.data[vpSet[pgnum].brr.size - 9] &= ~2;
    }
    CFDataRef	brrdata = CFDataCreate(NULL, vpSet[pgnum].brr.data, vpSet[pgnum].brr.size);
    CFDictionarySetValue(dict, kSaveKey_brrdata, brrdata);
    CFRelease(brrdata);

    AddNumToDictionary(dict, kSaveKey_looppoint, vpSet[pgnum].lp);
    CFNumberRef	num = CFNumberCreate(NULL, kCFNumberDoubleType, &vpSet[pgnum].rate);
    CFDictionarySetValue(dict, kSaveKey_samplerate, num);
    CFRelease(num);
    AddNumToDictionary(dict, kSaveKey_basekey, vpSet[pgnum].basekey);
    AddNumToDictionary(dict, kSaveKey_lowkey, vpSet[pgnum].lowkey);
    AddNumToDictionary(dict, kSaveKey_highkey, vpSet[pgnum].highkey);
    AddNumToDictionary(dict, kSaveKey_ar, vpSet[pgnum].ar);
    AddNumToDictionary(dict, kSaveKey_dr, vpSet[pgnum].dr);
    AddNumToDictionary(dict, kSaveKey_sl, vpSet[pgnum].sl);
    AddNumToDictionary(dict, kSaveKey_sr, vpSet[pgnum].sr);
    AddBooleanToDictionary(dict, kSaveKey_SustainMode, vpSet[pgnum].sustainMode);
    AddNumToDictionary(dict, kSaveKey_volL, vpSet[pgnum].volL);
    AddNumToDictionary(dict, kSaveKey_volR, vpSet[pgnum].volR);
    AddBooleanToDictionary(dict, kSaveKey_echo, vpSet[pgnum].echo);
    AddNumToDictionary(dict, kSaveKey_bank, vpSet[pgnum].bank);
    AddBooleanToDictionary(dict, kSaveKey_MonoMode, vpSet[pgnum].monoMode);
    AddBooleanToDictionary(dict, kSaveKey_PortamentoOn, vpSet[pgnum].portamentoOn);
    AddNumToDictionary(dict, kSaveKey_PortamentoRate, vpSet[pgnum].portamentoRate);
    AddNumToDictionary(dict, kSaveKey_NoteOnPriority, vpSet[pgnum].noteOnPriority);
    AddNumToDictionary(dict, kSaveKey_ReleasePriority, vpSet[pgnum].releasePriority);

    //元波形情報
    AddBooleanToDictionary(dict, kSaveKey_IsEmphasized, vpSet[pgnum].isEmphasized);
    if ( vpSet[pgnum].sourceFile[0] ) {
        CFURLRef	url =
            CFURLCreateFromFileSystemRepresentation(NULL, (UInt8*)vpSet[pgnum].sourceFile,
                    strlen(vpSet[pgnum].sourceFile), false);
        CFDataRef urlData = CFURLCreateData( NULL, url, kCFStringEncodingUTF8, false );
        CFDictionarySetValue(dict, kSaveKey_SourceFile, urlData);
        CFRelease(urlData);
        CFRelease(url);
    }

    //プログラム名
    if (vpSet[pgnum].pgname[0] != 0) {
        CFStringRef	str = CFStringCreateWithCString(NULL, vpSet[pgnum].pgname, kCFStringEncodingUTF8);
        CFDictionarySetValue(dict, kSaveKey_ProgName, str);
        CFRelease(str);
    }

    *data = dict;
    return 0;
}
예제 #2
0
파일: AEUtils.c 프로젝트: tkurita/AEUtils
OSErr AEDescCreateWithCFURL(CFURLRef url, AEDesc* outDescPtr)
{
    OSStatus err;
    CFDataRef data = CFURLCreateData(kCFAllocatorDefault, url, kCFStringEncodingUTF8, true);
    if (data != NULL) {
        err = AECreateDesc('furl', CFDataGetBytePtr(data),
                           CFDataGetLength(data), outDescPtr);
        CFRelease(data);
    } else {
        err = kCFURLErrorUnknown;
    }
    return err;
}
예제 #3
0
void wxDataObject::AddToPasteboard( void * pb, int itemID )
{
    PasteboardRef pasteboard = (PasteboardRef) pb;
   // get formats from wxDataObjects
    wxDataFormat *array = new wxDataFormat[ GetFormatCount() ];
    GetAllFormats( array );

    for (size_t i = 0; i < GetFormatCount(); i++)
    {
        wxDataFormat thisFormat = array[ i ];
    
        // add four bytes at the end for data objs like text that 
        // have a datasize = strlen but still need a buffer for the
        // string including trailing zero
        
        size_t datasize = GetDataSize( thisFormat );
        size_t sz = datasize + 4;
        void* buf = malloc( sz );
        if ( buf != NULL )
        {
            // empty the buffer because in some case GetDataHere does not fill buf
            memset( buf, 0, sz );
            if ( GetDataHere( array[ i ], buf ) )
            {
                int counter = 1 ;
                if ( thisFormat.GetType() == wxDF_FILENAME )
                {
                    // the data is D-normalized UTF8 strings of filenames delimited with \n
                    char *fname = strtok((char*) buf,"\n");
                    while (fname != NULL)
                    {
                        // translate the filepath into a fileurl and put that into the pasteobard
                        CFStringRef path = CFStringCreateWithBytes(NULL,(UInt8*)fname,strlen(fname),kCFStringEncodingUTF8,false);
                        CFURLRef url = CFURLCreateWithFileSystemPath(NULL, path , kCFURLPOSIXPathStyle, false);
                        CFRelease(path);
                        CFDataRef data = CFURLCreateData(NULL,url,kCFStringEncodingUTF8,true);
                        CFRelease(url);
                        PasteboardPutItemFlavor( pasteboard, (PasteboardItemID) counter,
                            (CFStringRef) thisFormat.GetFormatId() , data, kPasteboardFlavorNoFlags);
                        CFRelease( data );
                        counter++;
                        fname = strtok (NULL,"\n");
                    }
                    
                }
                else
                {
                    CFDataRef data = CFDataCreate( kCFAllocatorDefault, (UInt8*)buf, datasize );
                    if ( thisFormat.GetType() == wxDF_TEXT )
                         PasteboardPutItemFlavor( pasteboard, (PasteboardItemID) itemID,
                            CFSTR("com.apple.traditional-mac-plain-text") , data, kPasteboardFlavorNoFlags);
                    else
                        PasteboardPutItemFlavor( pasteboard, (PasteboardItemID) itemID,
                            (CFStringRef) thisFormat.GetFormatId() , data, kPasteboardFlavorNoFlags);
                    CFRelease( data );
                }
            }
            free( buf );
        }
    }

    delete [] array;
}