// // UpdateEffect2D // // Update effect data (TRUE if effect was playing) // Bool UpdateEffect2D(Effect *e, S32 pan, F32 priority, S32 vol) { // See if this effect is still being played if (Voice *voice = FindVoicePlayingEffect(e)) { AIL_set_sample_pan(voice->handle2D, pan); voice->priority = priority; AIL_set_sample_volume(voice->handle2D, vol); return (TRUE); } return (FALSE); }
// // Play2D // // Play a record as a 2D sample (TRUE if actually started) // Bool Play2D ( Effect *e, Record *r, S32 vol, U32 owner, F32 priority, S32 loop, S32 pan ) { ASSERT(e); ASSERT(r); // Request a 2D voice Voice *voice = Request(priority, FALSE, e->GetVoiceIndex()); if (!voice) { return (FALSE); } // Request the cache data Cache::Item *item = Cache::Request(r); if (!item) { // Unable to load data return (FALSE); } // Stop any sounds from this owner if (owner != NO_OWNER) { Output::StopByOwner(owner); } // The current time U32 time = AIL_ms_count(); // Are we under the minimum repeat time if ((time - r->lastUse) < MIN_REPEATTIME) { return (FALSE); } // Save info about this use r->lastUse = time; // Initialise the voice AIL_init_sample(voice->handle2D); // Initialise the sound effect data if (!AIL_set_sample_file(voice->handle2D, item->data, 0)) { LOG_WARN(("Ignoring possibly corrupted file '%s'", r->Name())); r->valid = FALSE; return (FALSE); } // Setup the voice voice->effect = e; voice->record = r; voice->owner = owner; voice->priority = priority; // Set the volume AIL_set_sample_volume(voice->handle2D, vol); // Set the stereo panning AIL_set_sample_pan(voice->handle2D, pan); // Set the loop count for this voice AIL_set_sample_loop_count(voice->handle2D, loop); // Start the sample playing AIL_start_sample(voice->handle2D); return (TRUE); }
bool TForm_Main::OpenFile() { // STOP!!! c_Button_Stop->Click(); // Let go... if (m_hSample) { AIL_release_sample_handle(m_hSample); m_hSample = NULL; } // Get rid of the buffer if it's already been loaded if (m_pFileBuffer) { AIL_mem_free_lock(m_pFileBuffer); m_pFileBuffer = NULL; } // Remember the file name m_CurFile = c_Edit_FileName->Text; // Er, don't load if it doesn't exist... if (!FileExists(m_CurFile)) { m_CurFile = ""; return false; } m_hSample = AIL_allocate_sample_handle(m_hDigDriver); if (!m_hSample) { ChangeStatus("Error allocating sample handle"); m_CurFile = ""; return false; } char *pFileName = m_CurFile.c_str(); // Bind to the file m_pFileBuffer = AIL_file_read(pFileName, NULL); if (!m_pFileBuffer) { ChangeStatus("Error opening " + m_CurFile + " (" + IntToStr(AIL_file_error()) + ")"); m_CurFile = ""; return false; } // Get the file size m_iFileSize = AIL_file_size(pFileName); AIL_init_sample(m_hSample); AIL_set_named_sample_file(m_hSample, pFileName, m_pFileBuffer, m_iFileSize, 0); AIL_set_sample_loop_count(m_hSample, 0); AIL_set_sample_volume(m_hSample, 127); AIL_set_sample_processor(m_hSample, DP_FILTER, m_hCurFilter); ChangeStatus("Loaded " + m_CurFile); return true; }