05 August 2011, 03:23 | #1 |
Registered User
Join Date: Sep 2009
Location: Norway
Posts: 1,711
|
Using AHI dev with SAS/C 6.58
So I finally got SAS/C 6.58 set up properly, and it compiles the C examples that were bundled with it.
I downloaded the latest AHI dev package, unpacked it and copied the header files to the include: assigned drawer. However, I found no library bundled with the AHI dev package, where do I find it? Or maybe compiling on the Amiga with libraries does not work like that..? I got an AHI example compiled, but it returned "Could not initialize AHI" when I ran it, and I do have AHI properly installed on my system. For instance, AHI with DeliTracker etc runs just fine. Halp, I want to code stuff with AHI. |
05 August 2011, 06:11 | #2 |
Registered User
Join Date: Sep 2007
Location: Melbourne/Australia
Posts: 4,400
|
Here ya go, should give you some ideas
Code:
/* ScummVM - Graphic Adventure Engine * * ScummVM is the legal property of its developers, whose names * are too numerous to list here. Please refer to the COPYRIGHT * file distributed with this source distribution. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * $URL$ * $Id$ * */ #include "backends/platform/amigaos3/amigaos3.h" #include "backends/mixer/amigaos3/amigaos3-mixer.h" #include "common/debug.h" #include "common/system.h" #include "common/config-manager.h" #include "common/textconsole.h" // Amiga includes #include <clib/exec_protos.h> #include "ahi-player-hook.h" #define DEFAULT_MIX_FREQUENCY 11025 AmigaOS3MixerManager* g_mixerManager; static void audioPlayerCallback() { g_mixerManager->callbackHandler(); } AmigaOS3MixerManager::AmigaOS3MixerManager() : _mixer(0), _audioSuspended(false) { g_mixerManager = this; } AmigaOS3MixerManager::~AmigaOS3MixerManager() { if (_mixer) { _mixer->setReady(false); if (audioCtrl) { debug(1, "deleting AHI_ControlAudio"); // Stop sounds. AHI_ControlAudio(audioCtrl, AHIC_Play, FALSE, TAG_DONE); if (_mixer) { _mixer->setReady(false); } AHI_UnloadSound(0, audioCtrl); AHI_FreeAudio(audioCtrl); audioCtrl = NULL; } if (audioRequest) { debug(1, "deleting AHIDevice"); CloseDevice((struct IORequest*)audioRequest); DeleteIORequest((struct IORequest*)audioRequest); audioRequest = NULL; DeleteMsgPort(audioPort); audioPort = NULL; AHIBase = NULL; } if (sample.ahisi_Address) { debug(1, "deleting soundBuffer"); FreeVec(sample.ahisi_Address); sample.ahisi_Address = NULL; } delete _mixer; } } void AmigaOS3MixerManager::init() { audioPort = (struct MsgPort*)CreateMsgPort(); if (!audioPort) { error("Could not create a Message Port for AHI"); } audioRequest = (struct AHIRequest*)CreateIORequest(audioPort, sizeof(struct AHIRequest)); if (!audioRequest) { error("Could not create an IO Request for AHI"); } // Open at least version 4. audioRequest->ahir_Version = 4; BYTE deviceError = OpenDevice(AHINAME, AHI_NO_UNIT, (struct IORequest*)audioRequest, NULL); if (deviceError) { error("Unable to open AHI Device: %s version 4", AHINAME); } // Needed by Audio Control? AHIBase = (struct Library *)audioRequest->ahir_Std.io_Device; uint32 desiredMixingfrequency = 0; // Determine the desired output sampling frequency. if (ConfMan.hasKey("output_rate")) { desiredMixingfrequency = ConfMan.getInt("output_rate"); } if (desiredMixingfrequency == 0) { desiredMixingfrequency = DEFAULT_MIX_FREQUENCY; } ULONG audioId = AHI_DEFAULT_ID; audioCtrl = AHI_AllocAudio( AHIA_AudioID, audioId, AHIA_MixFreq, desiredMixingfrequency, AHIA_Channels, numAudioChannels, AHIA_Sounds, 1, AHIA_PlayerFunc, createAudioPlayerCallback(audioPlayerCallback), AHIA_PlayerFreq, audioCallbackFrequency<<16, AHIA_MinPlayerFreq, audioCallbackFrequency<<16, AHIA_MaxPlayerFreq, audioCallbackFrequency<<16, TAG_DONE); if (!audioCtrl) { error("Could not create initialize AHI"); } // Get obtained mixing frequency. ULONG obtainedMixingfrequency = 0; AHI_ControlAudio(audioCtrl, AHIC_MixFreq_Query, (Tag)&obtainedMixingfrequency, TAG_DONE); debug(5, "Mixing frequency desired = %d Hz", desiredMixingfrequency); debug(5, "Mixing frequency obtained = %d Hz", obtainedMixingfrequency); // Calculate the sample factor. ULONG sampleCount = (ULONG)floor(obtainedMixingfrequency / audioCallbackFrequency); debug(5, "Calculated sample rate @ %u times per second = %u", audioCallbackFrequency, sampleCount); // 32 bits (4 bytes) are required per sample for storage (16bit stereo). sampleBufferSize = (sampleCount * AHI_SampleFrameSize(AHIST_S16S)); sample.ahisi_Type = AHIST_S16S; sample.ahisi_Address = AllocVec(sampleBufferSize, MEMF_PUBLIC|MEMF_CLEAR); sample.ahisi_Length = sampleCount; AHI_SetFreq(0, obtainedMixingfrequency, audioCtrl, AHISF_IMM); AHI_SetVol(0, 0x10000L, 0x8000L, audioCtrl, AHISF_IMM); AHI_LoadSound(0, AHIST_DYNAMICSAMPLE, &sample, audioCtrl); AHI_SetSound(0, 0, 0, 0, audioCtrl, AHISF_IMM); // Create the mixer instance and start the sound processing. assert(!_mixer); _mixer = new Audio::MixerImpl(g_system, obtainedMixingfrequency); assert(_mixer); _mixer->setReady(true); // Start feeding samples to sound hardware (and start the AHI callback!) AHI_ControlAudio(audioCtrl, AHIC_Play, TRUE, TAG_DONE); } void AmigaOS3MixerManager::callbackHandler() { assert(_mixer); _mixer->mixCallback((byte*)sample.ahisi_Address, sampleBufferSize); } void AmigaOS3MixerManager::suspendAudio() { AHI_ControlAudio(audioCtrl, AHIC_Play, FALSE, TAG_DONE); _audioSuspended = true; } int AmigaOS3MixerManager::resumeAudio() { if (!_audioSuspended) { return -2; } AHI_ControlAudio(audioCtrl, AHIC_Play, TRUE, TAG_DONE); _audioSuspended = false; return 0; } |
05 August 2011, 06:59 | #3 |
Coder/webmaster/gamer
Join Date: Oct 2001
Location: Canberra/Australia
Posts: 2,641
|
My AmiArcadia emulator is written in SAS/C, uses AHI, and is open source. So you may want to look there. http://amigan.1emu.net/releases/AmiArcadia.lha
|
05 August 2011, 07:24 | #4 |
Registered User
Join Date: Sep 2009
Location: Norway
Posts: 1,711
|
@NovaCoder: Awesome, thanks, this is just what I needed.
Sorry Minuous, got the help I needed already. |
08 August 2011, 15:10 | #5 |
Registered User
Join Date: Sep 2009
Location: Norway
Posts: 1,711
|
|
09 August 2011, 02:50 | #6 |
Registered User
Join Date: Sep 2007
Location: Melbourne/Australia
Posts: 4,400
|
Hiya,
Download ScummVM AGA from AmiNet....all the source code is there To create the AHI callback hook you'll also need to include the SDI header files |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
new AHI pages layout and AHI-archive | Bamiga2002 | Amiga scene | 12 | 20 December 2007 14:44 |
whdload dev | bobbybearing | Coders. General | 6 | 30 July 2004 03:17 |
Best dev tool | Oscar Castillo | Coders. General | 6 | 24 April 2004 03:51 |
console dev | staticgerbil | Amiga scene | 8 | 13 March 2003 11:20 |
Dev Kit | Fissuras | Coders. General | 1 | 05 November 2002 02:08 |
|
|