@@ -81,16 +81,14 @@ int main(void) {
8181 // Initialize the engine.
8282 BarelyEngineConfig config = BARELY_ENGINE_CONFIG_DEFAULT (kSampleRate );
8383 config .max_frame_count = kFrameCount ;
84- int32_t allocation_size = 0 ;
85- BarelyEngineConfig_GetRequiredAllocationSize (& config , & allocation_size );
84+ const int32_t allocation_size = BarelyEngineConfig_GetRequiredAllocationSize (& config );
8685 printf ("Allocating %.2f KB...\n" , (float )allocation_size / 1024.0f );
8786 void * allocation = malloc (allocation_size );
8887
89- BarelyEngine * engine = NULL ;
90- BarelyEngine_Create (& config , allocation , allocation_size , & engine );
88+ BarelyEngine * engine = BarelyEngine_Create (& config , allocation , allocation_size );
9189 BarelyEngine_SetTempo (engine , kTempo );
9290
93- BarelyEngine_CreateInstrument (engine , & g_instrument_id );
91+ g_instrument_id = BarelyEngine_CreateInstrument (engine );
9492 BarelyInstrument_SetControl (engine , g_instrument_id , BarelyInstrumentControlType_kGain , kGain );
9593 BarelyInstrument_SetControl (engine , g_instrument_id , BarelyInstrumentControlType_kOscMix , 1.0f );
9694 BarelyInstrument_SetControl (engine , g_instrument_id , BarelyInstrumentControlType_kOscShape ,
@@ -100,13 +98,11 @@ int main(void) {
10098 BarelyInstrument_SetControl (engine , g_instrument_id , BarelyInstrumentControlType_kRelease ,
10199 kRelease );
102100
103- uint32_t performer_id = 0 ;
104- BarelyEngine_CreatePerformer (engine , & performer_id );
105- uint32_t task_ids [kMelodyNoteCount ];
101+ const uint32_t performer_id = BarelyEngine_CreatePerformer (engine );
106102 for (int i = 0 ; i < kMelodyNoteCount ; ++ i ) {
107103 BarelyPerformer_CreateTask (engine , performer_id , kMelodyPositions [i ],
108104 kMelodyPositions [i + 1 ] - kMelodyPositions [i ], 0 , TaskCallback ,
109- engine , & task_ids [ i ] );
105+ engine );
110106 }
111107
112108 // Initialize the audio device.
0 commit comments