basesound --> load



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 17/01/2006 at 14:42, xxxxxxxx wrote:

    User Information:
    Cinema 4D Version:   9.5 
    Platform:   Windows  ;   
    Language(s) :     C++  ;

    ---------
    i have a problem with loading sound with basesound class. i createred sound which is BaseSound pointer (as basesound doesn't seem to have a constructor o.O), but sound->load doesn't work... i think there must be something missing before load, but i can't find what... any help would be highly appreciated.



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 17/01/2006 at 22:26, xxxxxxxx wrote:

    Like most C4D 'Base' classes, there are no direct constructor/destructor methods. You must use 'Alloc' and 'Free' to allocated and free the class:

    BaseSound* sound = BaseSound::Alloc();
    BaseSound::Free(sound);

    Note that Load() only works with WAV sound files. It is possible that certain codecs are not supported (unless they are installed).

    Here is working source that I use (in conjunction with animation tracks) :

    if (type == Ssound)  
    {  
         // <Bool:On|Off>  
         if (!tokenReader.ParseBool(&fileReader;, &boolVal;, "on", "off")) return FALSE;  
         data->SetBool(ID_SOUND_ONOFF, boolVal);  
         // "<String:Sound_Filename>"  
         SoundSequence *sseq = static_cast<SoundSequence*>(seq);  
         BaseSound* bsound;  
         if (!(bsound = sseq->GetSound()))  
         {  
              ErrorException::Throw(GeLoadString(ERROR_MEMORY_TEXT), "AnimatLOAD.ReadSequence.bsound");  
              return FALSE;  
         }  
         if (!tokenReader.ParseQuotedString(&fileReader;, &name;))  
         {  
              BaseSound::Free(bsound);  
              return FALSE;  
         }  
         Filename soundFile = Filename(filename);  
         soundFile.SetFile(Filename(name));  
         if (bsound->Load(soundFile))  
         {  
              sseq->SetSound(bsound);  
              sseq->SetParameter(DescID(ID_SOUND_NAME), name, DESCFLAGS_DONTCHECKMINMAX);  
         }  
         else ErrorException::Throw(GeLoadString(ERROR_OPENFILE_TEXT), "Sound file:", name);  
         BaseSound::Free(bsound);  
    }  
    

    HTH,



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 18/01/2006 at 03:41, xxxxxxxx wrote:

    thanks, solved that, works ok now, but i got something really weird instead... I have a separate new class, in which sounddata pointer has to be created (because getsample needs pointer SData to work with), but it doesn't seem to work. Cinema throws "The instruction at "----" referenced memory at "----"..." error... it works if i declare wariable sd like SData sd; but doesnt with SData* sd=new SData();... that one works just fine in the main plugin cpp (NodeData::Message) though... any ideas?

    thanks in advance,
    regards



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 18/01/2006 at 07:44, xxxxxxxx wrote:

    ah, found it out myself. in the end it had nothing to do with the sdata :>


Log in to reply