Exemplo n.º 1
0
int Player::openSong(std::string songName)
{
	//close current song if there is currently one loaded
	if (m_songLoaded)
	{
		(void) ErrorCheck(m_channel->stop());
		(void) ErrorCheck(m_song->release());
	}

	//Open the song as a stream
	m_result = m_system->createStream(songName.c_str(), FMOD_DEFAULT, 0, &m_song);
	m_error = ErrorCheck(m_result);

	if (!m_error)
	{
		//assign a channel to the song and play it upon open
		m_result = m_system->playSound(m_song, NULL, false, &m_channel);
		m_error = ErrorCheck(m_result);
	}

	//check for errors and return accordingly
	if (m_error)
	{
		m_songLoaded = false;
		return OPEN_FAILURE;
	}
	else
	{
		m_channel->setLoopCount(0);
		m_songLoaded = true;
		return OPEN_SUCCESS;
	}
}
Exemplo n.º 2
0
	void FMOD_System::CreateSounds( const SoundFilenameMap& soundFilenames )
	{
		auto isPresent = [=]( const std::string& key ) -> bool
		{
			return ( soundFilenames.find( key ) != soundFilenames.end() ) ? true : false;
		};

		if( isPresent( "bgmusic" ) )
		{
			ErrorCheck( system->createStream( soundFilenames.at("bgmusic").c_str(), FMOD_LOOP_NORMAL | FMOD_CREATESTREAM,
				nullptr, &bgmusic ) );
			bgmusic->setDefaults( 44100, 0.025f, 0.f, 128 );
		}
		if( isPresent( "jet" ) )
		{
			ErrorCheck( system->createSound( soundFilenames.at( "jet" ).c_str(), FMOD_3D, nullptr, &jet ) );
			jet->setDefaults( 44100, 0.75f, 0.f, 128 );
		}
		if( isPresent( "vent" ) )
		{
			ErrorCheck( system->createSound( soundFilenames.at( "vent" ).c_str(), FMOD_3D | FMOD_LOOP_NORMAL,
				nullptr, &ventSound ) );
			ventSound->setDefaults( 44100, 0.3f, 0.f, 128 );
		}
		if( isPresent( "collision" ) )
		{
			ErrorCheck( system->createSound( soundFilenames.at( "collision" ).c_str(), FMOD_3D, nullptr, &collision ) );
			collision->setDefaults( 44100, 5.f, 0.f, 128 );
		}
		if( isPresent( "roll" ) )
		{
			ErrorCheck( system->createSound( soundFilenames.at( "roll" ).c_str(), FMOD_3D, nullptr, &roll ) );
			roll->setDefaults( 44100, 2.f, 0.f, 128 );
		}
	}
// This function prompts user to input searchInt based on search type
int GetSearchInt(int& choice)
{
	int searchInt;	// IN & OUT & CALC - int to searched, input
					// 					 by user
	searchInt = 0;  // Initialize searchInt to 0

	// Will prompt user to input searchInt based on menu choice
	switch(choice)
	{
	case YEARSEARCH:
		cout << "\nWhich year are you looking for? ";
		searchInt = ErrorCheck(1878, 3000);
		cout << "\nSearching for the year " << searchInt << endl;
		break;
	case RATINGSEARCH:
		cout << "\nWhich rating are you looking for? ";
		searchInt = ErrorCheck(0, 9);
		cout << "\nSearching for the rating " << searchInt << endl;
		break;
	default:
		cout << "\nYou shouldn't have done that.\n";
		break;
	}

	// Returns int to be searched
	return searchInt;
}
Exemplo n.º 4
0
bool AudioSystem::Load2DSound(const string& filepath, FMOD::Sound** sound){
	FMOD_RESULT result = m_system->createSound(filepath.c_str(), FMOD_2D, 0, &*sound);
	if (!ErrorCheck(result)) return false;
	result = (*sound)->setMode(FMOD_LOOP_OFF);
	if (!ErrorCheck(result)) return false;
	return true;
}
Exemplo n.º 5
0
void Renderer::createBuffer(VkDeviceSize size, VkBufferUsageFlags usage, VkMemoryPropertyFlags memory_properties, VkBuffer & buffer, VkDeviceMemory & buffer_memory) {
	VkBufferCreateInfo buffer_create_info{};
	buffer_create_info.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO;
	buffer_create_info.size = size;
	buffer_create_info.usage = usage;
	buffer_create_info.sharingMode = VK_SHARING_MODE_EXCLUSIVE;

	ErrorCheck(vkCreateBuffer(_device, &buffer_create_info, nullptr, &buffer));

	VkMemoryRequirements mem_requirements{};
	vkGetBufferMemoryRequirements(_device, buffer, &mem_requirements);

	uint32_t type_filter = mem_requirements.memoryTypeBits;
	uint32_t memory_type;

	for (uint32_t i = 0; i < _gpu_memory_properties.memoryTypeCount; i++) {
		if ((type_filter & (1 << i)) && (_gpu_memory_properties.memoryTypes[i].propertyFlags & memory_properties) == memory_properties) {
			memory_type = i;
			break;
		}
	}

	VkMemoryAllocateInfo memory_allocate_info{};
	memory_allocate_info.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO;
	memory_allocate_info.allocationSize = mem_requirements.size;
	memory_allocate_info.memoryTypeIndex = memory_type;

	ErrorCheck(vkAllocateMemory(_device, &memory_allocate_info, nullptr, &buffer_memory));
	ErrorCheck(vkBindBufferMemory(_device, buffer, buffer_memory, 0));
}
Exemplo n.º 6
0
int SoundManager::Play3D(string Name, SoundType Type, XMFLOAT3 Position, bool Loop)
{
    if(!Exists(Name))
    {
        DebugScreen::GetInstance()->AddLogMessage("Sound: \"" + Name + "\" does not exist.", Red);
        return -1;
    }

    if(Loop)
        gSoundIterator->second.second->setMode(FMOD_LOOP_NORMAL);

    ErrorCheck(gSystem->playSound(FMOD_CHANNEL_FREE, gSoundIterator->second.second, true, &gChannel));

    ErrorCheck(gChannel->setPaused(false));

    switch(Type)
    {
    case Song:
        gChannel->setVolume( gMusicVolume * gMasterVolume );
        break;

    case SFX:
        gChannel->setVolume( gEffectVolume * gMasterVolume );
        break;
    }

    FMOD_VECTOR	tVelocity	=	{0, 0, 0};
    gResult	=	gChannel->set3DAttributes(&gListenerPosition, &tVelocity);
    ErrorCheck(gResult);

    gPlayingSounds->push_back(new PlayingSound(PSIndex( gUniqueIndex, Name ), PSEntry( Type, gChannel )));
    ++gUniqueIndex;

    return gUniqueIndex - 1;
}
Exemplo n.º 7
0
void Window::_InitSwapchainImages()
{
	_swapchain_images.resize( _swapchain_image_count );
	_swapchain_image_views.resize( _swapchain_image_count );

	ErrorCheck( vkGetSwapchainImagesKHR( _renderer->GetVulkanDevice(), _swapchain, &_swapchain_image_count, _swapchain_images.data() ) );

	for( uint32_t i=0; i < _swapchain_image_count; ++i ) {
		VkImageViewCreateInfo image_view_create_info {};
		image_view_create_info.sType				= VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO;
		image_view_create_info.image				= _swapchain_images[ i ];
		image_view_create_info.viewType				= VK_IMAGE_VIEW_TYPE_2D;
		image_view_create_info.format				= _surface_format.format;
		image_view_create_info.components.r			= VK_COMPONENT_SWIZZLE_IDENTITY;
		image_view_create_info.components.g			= VK_COMPONENT_SWIZZLE_IDENTITY;
		image_view_create_info.components.b			= VK_COMPONENT_SWIZZLE_IDENTITY;
		image_view_create_info.components.a			= VK_COMPONENT_SWIZZLE_IDENTITY;
		image_view_create_info.subresourceRange.aspectMask			= VK_IMAGE_ASPECT_COLOR_BIT;
		image_view_create_info.subresourceRange.baseMipLevel		= 0;
		image_view_create_info.subresourceRange.levelCount			= 1;
		image_view_create_info.subresourceRange.baseArrayLayer		= 0;
		image_view_create_info.subresourceRange.layerCount			= 1;

		ErrorCheck( vkCreateImageView( _renderer->GetVulkanDevice(), &image_view_create_info, nullptr, &_swapchain_image_views[ i ] ) );
	}
}
Exemplo n.º 8
0
/***********************************************************************
 *
 * Function:    sync_MergeFromPilot_fast
 *
 * Summary:     er, fast merge from Palm to desktop
 *
 * Parameters:  None
 *
 * Returns:     0 if success, nonzero otherwise
 *
 ***********************************************************************/
static int
sync_MergeFromPilot_fast(SyncHandler * sh, int dbhandle,
			 RecordModifier rec_mod)
{
	int 	result = 0;
	PilotRecord *precord 	= sync_NewPilotRecord(DLP_BUF_SIZE);
	DesktopRecord *drecord 	= NULL;
	RecordQueue rq 		= { 0, NULL };
	pi_buffer_t *recbuf = pi_buffer_new(DLP_BUF_SIZE);
	
	while (dlp_ReadNextModifiedRec(sh->sd, dbhandle, recbuf,
				       &precord->recID, NULL,
				       &precord->flags,
				       &precord->catID) >= 0) {
		int count = rq.count;
		precord->len = recbuf->used;
		if (precord->len > DLP_BUF_SIZE)
			precord->len = DLP_BUF_SIZE;
		memcpy(precord->buffer, recbuf->data, precord->len);
		ErrorCheck(sh->Match(sh, precord, &drecord));
		ErrorCheck(sync_record
			   (sh, dbhandle, drecord, precord, &rq, rec_mod));

		if (drecord && rq.count == count)
			ErrorCheck(sh->FreeMatch(sh, drecord));
	}
	pi_buffer_free(recbuf);
	sync_FreePilotRecord(precord);

	result = sync_MergeFromPilot_process(sh, dbhandle, &rq, rec_mod);

	return result;
}
Exemplo n.º 9
0
void AudioSystem::Play3DSound(FMOD::Sound* sound, const FMOD_VECTOR& position, FMOD::Channel** channel){
	FMOD_RESULT result = m_system->playSound(FMOD_CHANNEL_FREE, sound, true, &*channel);
	ErrorCheck(result);
	result = (*channel)->set3DAttributes(&position, 0);
	ErrorCheck(result);
	result = (*channel)->setPaused(false);
	ErrorCheck(result);
}
Exemplo n.º 10
0
	AudioClip::AudioClip(const string& filename, bool streamed)
		: m_channel(0), m_playing(false), m_paused(false), m_looping(false), m_volume(1.0f)
	{
		if (!streamed)
			ErrorCheck(Audio::AudioSystem().createSound(filename.c_str(), FMOD_DEFAULT, 0, &m_sound));
		else
			ErrorCheck(Audio::AudioSystem().createStream(filename.c_str(), FMOD_DEFAULT, 0, &m_sound));
	}
Exemplo n.º 11
0
void AudioSystem::Shut(){
	if (m_system != nullptr){
		FMOD_RESULT result;
		result = m_system->close();
		ErrorCheck(result);
		result = m_system->release();
		ErrorCheck(result);
	}
}
Exemplo n.º 12
0
void										Summerface::AddWindow								(const std::string& aName, SummerfaceWindow_Ptr aWindow)
{
	ErrorCheck(aWindow, "Summerface::AddWindow: Window is not a valid pointer. [Name: %s]", aName.c_str());
	ErrorCheck(Windows.find(aName) == Windows.end(), "Summerface::AddWindow: Window with name is already present. [Name: %s]", aName.c_str());

	Windows[aName] = aWindow;
	aWindow->SetInterface(shared_from_this(), aName);
	ActiveWindow = aName;
}
Exemplo n.º 13
0
bool AudioSystem::Load3DSound(const string& filepath, FMOD::Sound** sound){
	FMOD_RESULT result = m_system->createSound(filepath.c_str(), FMOD_3D, 0, &*sound);
	if (!ErrorCheck(result)) return false;
	result = (*sound)->set3DMinMaxDistance(0.5f * m_distance_factor, 8.0f * m_distance_factor);
	if (!ErrorCheck(result)) return false;
	result = (*sound)->setMode(FMOD_LOOP_OFF);
	if (!ErrorCheck(result)) return false;

	return true;
}
Exemplo n.º 14
0
  bool AudioFMOD::Load(FMOD::Studio::Bank*& bank, const std::string & path)
  {
    Trace("Loading '" + path + "'");
    // Load the bank into the sound system
    if (!ErrorCheck(System->loadBankFile(path.c_str(), FMOD_STUDIO_LOAD_BANK_NORMAL, &bank)))
      return false;

    // Now that the bank is finished loading, load its sample data
    ErrorCheck(bank->loadSampleData());
    return true;
  }
Exemplo n.º 15
0
 void AudioFMOD::Initialize()
 {
   Trace("Initializing Low Level and Studio system objects... ");
   // Create the Low Level System
   ErrorCheck(FMOD::System_Create(&System.LowLevel));
   // Create the Studio System
   ErrorCheck(System->create(&System.Studio));
   // Set FMOD low level studio pointer
   ErrorCheck(System->getLowLevelSystem(&System.LowLevel));
   // Initialize it
   unsigned maxChannels = 36;
   ErrorCheck(System->initialize(maxChannels, FMOD_STUDIO_INIT_NORMAL, FMOD_INIT_NORMAL, nullptr));
 }
Exemplo n.º 16
0
void Renderer::_EndSingleTimeCommands(VkCommandPool pool, VkCommandBuffer commandBuffer) {
	ErrorCheck(vkEndCommandBuffer(commandBuffer));

	VkSubmitInfo submit_info {};
	submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;
	submit_info.commandBufferCount = 1;
	submit_info.pCommandBuffers = &commandBuffer;

	ErrorCheck(vkQueueSubmit(_queue, 1, &submit_info, VK_NULL_HANDLE));
	ErrorCheck(vkQueueWaitIdle(_queue));

	vkFreeCommandBuffers(_device, pool, 1, &commandBuffer);
}
Exemplo n.º 17
0
void Window::_InitSwapchain()
{
//	This code is old and the fixed one is below
//	if( _swapchain_image_count > _surface_capabilities.maxImageCount ) _swapchain_image_count = _surface_capabilities.maxImageCount;
//	if( _swapchain_image_count < _surface_capabilities.minImageCount + 1 ) _swapchain_image_count = _surface_capabilities.minImageCount + 1;

	// The code above will work just fine in our tutorials and likely on every possible implementation of vulkan as well
	// so this change isn't that important. Just to be absolutely sure we don't go over or below the given limits we should check this a
	// little bit different though. maxImageCount can actually be zero in which case the amount of swapchain images do not have an
	// upper limit other than available memory. It's also possible that the swapchain image amount is locked to a certain
	// value on certain systems. The code below takes into consideration both of these possibilities.
	if( _swapchain_image_count < _surface_capabilities.minImageCount + 1 ) _swapchain_image_count = _surface_capabilities.minImageCount + 1;
	if( _surface_capabilities.maxImageCount > 0 ) {
		if( _swapchain_image_count > _surface_capabilities.maxImageCount ) _swapchain_image_count = _surface_capabilities.maxImageCount;
	}

	VkPresentModeKHR present_mode = VK_PRESENT_MODE_FIFO_KHR;
	{
		uint32_t present_mode_count = 0;
		ErrorCheck( vkGetPhysicalDeviceSurfacePresentModesKHR( _renderer->GetVulkanPhysicalDevice(), _surface, &present_mode_count, nullptr ) );
		std::vector<VkPresentModeKHR> present_mode_list( present_mode_count );
		ErrorCheck( vkGetPhysicalDeviceSurfacePresentModesKHR( _renderer->GetVulkanPhysicalDevice(), _surface, &present_mode_count, present_mode_list.data() ) );
		for( auto m : present_mode_list ) {
			if( m == VK_PRESENT_MODE_MAILBOX_KHR ) present_mode = m;
		}
	}

	VkSwapchainCreateInfoKHR swapchain_create_info {};
	swapchain_create_info.sType						= VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR;
	swapchain_create_info.surface					= _surface;
	swapchain_create_info.minImageCount				= _swapchain_image_count;
	swapchain_create_info.imageFormat				= _surface_format.format;
	swapchain_create_info.imageColorSpace			= _surface_format.colorSpace;
	swapchain_create_info.imageExtent.width			= _surface_size_x;
	swapchain_create_info.imageExtent.height		= _surface_size_y;
	swapchain_create_info.imageArrayLayers			= 1;
	swapchain_create_info.imageUsage				= VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
	swapchain_create_info.imageSharingMode			= VK_SHARING_MODE_EXCLUSIVE;
	swapchain_create_info.queueFamilyIndexCount		= 0;
	swapchain_create_info.pQueueFamilyIndices		= nullptr;
	swapchain_create_info.preTransform				= VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR;
	swapchain_create_info.compositeAlpha			= VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR;
	swapchain_create_info.presentMode				= present_mode;
	swapchain_create_info.clipped					= VK_TRUE;
	swapchain_create_info.oldSwapchain				= VK_NULL_HANDLE;

	ErrorCheck( vkCreateSwapchainKHR( _renderer->GetVulkanDevice(), &swapchain_create_info, nullptr, &_swapchain ) );

	ErrorCheck( vkGetSwapchainImagesKHR( _renderer->GetVulkanDevice(), _swapchain, &_swapchain_image_count, nullptr ) );
}
Exemplo n.º 18
0
void OpenCLBase::GetPlatformInfo(cl_platform_id id) {
	// 
	size_t length;
	cl_int errorCode;

	errorCode = clGetPlatformInfo(id, CL_PLATFORM_PROFILE, 0, NULL, &length);
	ErrorCheck("clGetPlatformInfo", errorCode);

	char* param = reinterpret_cast<char*>(malloc(length * sizeof(char)));
	errorCode = clGetPlatformInfo(id, CL_PLATFORM_PROFILE, length, param, NULL);
	ErrorCheck("clGetPlatformInfo", errorCode);
		
	cout << param << endl;

	free(param);
}
Exemplo n.º 19
0
void Renderer::_InitRenderPass() {
	VkAttachmentDescription color_attachment {};
	color_attachment.format = _window->getSurfaceFormat().format;
	color_attachment.samples = VK_SAMPLE_COUNT_1_BIT;
	color_attachment.loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR;
	color_attachment.storeOp = VK_ATTACHMENT_STORE_OP_STORE;
	color_attachment.stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE;
	color_attachment.stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE;
	color_attachment.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED;
	color_attachment.finalLayout = VK_IMAGE_LAYOUT_PRESENT_SRC_KHR;

	VkAttachmentDescription depth_attachment {};
	depth_attachment.format = findSupportedFormat(
		{ VK_FORMAT_D32_SFLOAT, VK_FORMAT_D32_SFLOAT_S8_UINT, VK_FORMAT_D24_UNORM_S8_UINT },
		VK_IMAGE_TILING_OPTIMAL,
		VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT
	);
	depth_attachment.samples = VK_SAMPLE_COUNT_1_BIT;
	depth_attachment.loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR;
	depth_attachment.storeOp = VK_ATTACHMENT_STORE_OP_DONT_CARE;
	depth_attachment.stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE;
	depth_attachment.stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE;
	depth_attachment.initialLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
	depth_attachment.finalLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;

	VkAttachmentReference color_attachment_reference {};
	color_attachment_reference.attachment = 0;
	color_attachment_reference.layout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;

	VkAttachmentReference depth_attachment_reference {};
	depth_attachment_reference.attachment = 1;
	depth_attachment_reference.layout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;

	VkSubpassDescription subpass{};
	subpass.pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS;
	subpass.colorAttachmentCount = 1;
	subpass.pColorAttachments = &color_attachment_reference;
	subpass.pDepthStencilAttachment = &depth_attachment_reference;

	VkSubpassDependency dependency {};
	dependency.srcSubpass = VK_SUBPASS_EXTERNAL;
	dependency.dstSubpass = 0;
	dependency.srcStageMask = VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT;
	dependency.srcAccessMask = VK_ACCESS_MEMORY_READ_BIT;
	dependency.dstStageMask = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
	dependency.dstAccessMask = VK_ACCESS_COLOR_ATTACHMENT_READ_BIT | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT;

	std::array<VkAttachmentDescription, 2> attachments = { color_attachment, depth_attachment };

	VkRenderPassCreateInfo render_pass_create_info {};
	render_pass_create_info.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO;
	render_pass_create_info.attachmentCount = (uint32_t)attachments.size();
	render_pass_create_info.pAttachments = attachments.data();
	render_pass_create_info.subpassCount = 1;
	render_pass_create_info.pSubpasses = &subpass;
	render_pass_create_info.dependencyCount = 1;
	render_pass_create_info.pDependencies = &dependency;

	ErrorCheck(vkCreateRenderPass(_device, &render_pass_create_info, nullptr, &_render_pass));
}
Exemplo n.º 20
0
void SoundManager::Stop(int Index)
{
    for(int i = gPlayingSounds->size() - 1; i >= 0; --i)
    {
        PlayingSound*	tSound	=	gPlayingSounds->at(i);
        bool	tPlaying	=	false;
        if ( tSound->first.first == Index)
        {
            PSEntry	tEntry	=	tSound->second;
            ErrorCheck( tEntry.second->isPlaying( &tPlaying ) );

            if(tPlaying)
            {
                gPlayingSounds->erase(gPlayingSounds->begin() + i);
                tEntry.second->stop();
                delete tSound;
                return;
            }
            else
            {
                gPlayingSounds->erase(gPlayingSounds->begin() + i);
            }
        }
    }

    DebugScreen::GetInstance()->AddLogMessage("Sound: Trying to stop index " + to_string((long double)Index) + ", but it is not playing.", Red);
}
Exemplo n.º 21
0
void SoundManager::Stop(string Name)
{
    if(!Exists(Name))
    {
        DebugScreen::GetInstance()->AddLogMessage("Sound: \"" + Name + "\" does not exist.", Red);
        return;
    }

    for(int i = gPlayingSounds->size() - 1; i >= 0; --i)
    {
        PlayingSound*	tSound	=	gPlayingSounds->at(i);
        bool	tPlaying	=	false;
        if ( tSound->first.second == Name)
        {
            PSEntry	tEntry	=	tSound->second;
            ErrorCheck( tEntry.second->isPlaying( &tPlaying ) );

            if(tPlaying)
            {
                gPlayingSounds->erase(gPlayingSounds->begin() + i);
                tEntry.second->stop();
                delete tSound;
                return;
            }
            else
            {
                gPlayingSounds->erase(gPlayingSounds->begin() + i);
            }
        }
    }

    DebugScreen::GetInstance()->AddLogMessage("Sound: Trying to stop \"" + Name + "\", but it is not playing.", Red);
}
Exemplo n.º 22
0
	// Start playing a song
	FMOD::Channel *Song::Start(bool paused)
	{
		// Channel volume will be set to 1.0f (max) automatically
		ErrorCheck(engine->FMOD()->playSound(FMOD_CHANNEL_FREE, resource.get(), true, &channel));

		// Add to channel group (for master volume)
		if (channelGroup)
			channel->setChannelGroup(channelGroup);

		// Songs repeat forever by default
		channel->setLoopCount(-1);
		channel->setMode(FMOD_LOOP_NORMAL);

		// Flush buffer to ensure loop logic is executed
		channel->setPosition(0, FMOD_TIMEUNIT_MS);

		// Set paused or not as applicable
		if (!paused)
			channel->setPaused(paused);

		// Cancel any fade that was previously applied
		fade = false;

		return channel;
	}
Exemplo n.º 23
0
	// Per-frame sound system update
	void SimpleFMOD::Update()
	{
		ErrorCheck(system->update());

		for (auto &r : updateableResources)
			r->Update();
	}
Exemplo n.º 24
0
void AudioSystem::UpdatePosition(float x, float y, float z){
	m_position.x = x;
	m_position.y = y;
	m_position.z = z;
	FMOD_RESULT result = m_system->set3DListenerAttributes(0, &m_position, 0, 0, 0);
	ErrorCheck(result);
}
Exemplo n.º 25
0
void SoundManager::Init( )
{
	//FMOD 초기화 
	//FMOD 함수는 모두 결과값을 리턴한다. 따라서 에러체크가 가능하다.
	r = System_Create( &m_pFmod );
	ErrorCheck( r );

	r = m_pFmod->init( MAX_SOUND_COUNT, FMOD_INIT_NORMAL, NULL );
	ErrorCheck( r );
	m_volume = 0.5f;

	for (int i = 0; i < MAX_SOUND_COUNT; i++)
	{
		m_pCh[i]->setVolume( m_volume );
	}
}
Exemplo n.º 26
0
/*
FUNCTION: Packetize
DATE: 11/30/2015
REVISIONS: v2 - adjusted checksum
DESIGNER: Thomas & Allen & Dylan
PROGRAMMER: Thomas & Allen & Dylan
INTERFACE: void Packetize(CHAR *buf, CHAR *packet)
			CHAR *buf : raw character to read from
			CHAR *packet : character array to store the packet in
RETURNS: void

NOTES: packet should be large enough to hold a packet (516 bytes)
		Performs the checksum calculations
*/
void Packetize(CHAR *buf, CHAR *packet) {
	int i, j=4;
	DWORD sum = 0;
	for (i = 0; i < 512; i++) {
		packet[i] = 0;
	}
	packet[0] = SOH;
	//TODO: make this check which sync bit to write
	packet[1] = SYNC_0;
	// zero the 2 checksum bytes
	packet[2] = 0;
	packet[3] = 0;
	// copy until end of file (character read is 0 or 512 bytes read)
	for (i = 0; buf[i] != 0 && i < DATALENGTH;) {
		packet[j++] = buf[i++];

	} 
	// insert EOT if  it's not a full packet
	if (i < 512) {
		packet[j] = EOT;
	}
	// calculate checksum
	for (i = 0; i < j; i++) {
		sum += packet[i];
	}
	// retrieve the most significant byte and convert to char
	// packet[2] = sum & 0xff;
	packet[2] = (sum & 0x0000ff00) /256;
	// repeat for least significant byte
	packet[3] = (sum & 0x000000ff);
	// check the packet locally for errors
	OutputDebugString(ErrorCheck(packet) ? "Checksum reversed\n" : "Checksum failed\n");
 }
Exemplo n.º 27
0
void ae3d::GfxDevice::SetRenderTarget( RenderTexture* target, unsigned cubeMapFace )
{
    if (target != nullptr && target->GetFBO() == GfxDeviceGlobal::cachedFBO && cubeMapFace == 0)
    {
        return;
    }
    if (target == nullptr && GfxDeviceGlobal::cachedFBO == GfxDeviceGlobal::systemFBO)
    {
        return;
    }

    const GLuint fbo = target != nullptr ? target->GetFBO() : GfxDeviceGlobal::systemFBO;
    glBindFramebuffer( GL_FRAMEBUFFER, fbo );
    GfxDeviceGlobal::cachedFBO = fbo;

    if (target && target->IsCube())
    {
        const unsigned glCubeMapFace = GL_TEXTURE_CUBE_MAP_POSITIVE_X + cubeMapFace;
        System::Assert( glCubeMapFace >= GL_TEXTURE_CUBE_MAP_POSITIVE_X && glCubeMapFace <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, "Invalid cube map face." );
        glFramebufferTexture2D( GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, glCubeMapFace, target->GetID(), 0 );
    }
    
    if (target != nullptr)
    {
        glViewport( 0, 0, target->GetWidth(), target->GetHeight() );
    }
    else
    {
        ae3d::System::Assert( GfxDeviceGlobal::backBufferWidth > 0, "invalid backbuffer dimension" );
        glViewport( 0, 0, GfxDeviceGlobal::backBufferWidth, GfxDeviceGlobal::backBufferHeight );
    }

    ErrorCheckFBO();
    ErrorCheck( "SetRenderTarget end" );
}
Exemplo n.º 28
0
// --------------------
// NodeHarnessWin implementation
NodeHarnessWin::NodeHarnessWin(BRect frame, const char *title)
    :	BWindow(frame, title, B_TITLED_WINDOW, B_NOT_RESIZABLE | B_ASYNCHRONOUS_CONTROLS),
      mToneNode(NULL), mIsConnected(false), mIsRunning(false)
{
    // build the UI
    BRect r(10, 10, 100, 40);
    mConnectButton = new BButton(r, "Connect", "Connect", new BMessage(BUTTON_CONNECT));
    mConnectButton->SetEnabled(true);
    AddChild(mConnectButton);
    r.OffsetBy(0, 40);
    mStartButton = new BButton(r, "Start", "Start", new BMessage(BUTTON_START));
    mStartButton->SetEnabled(false);
    AddChild(mStartButton);
    r.OffsetBy(0, 40);
    mStopButton = new BButton(r, "Stop", "Stop", new BMessage(BUTTON_STOP));
    mStopButton->SetEnabled(false);
    AddChild(mStopButton);

    // e.moon 2jun99: create the node
    BMediaRoster* roster = BMediaRoster::Roster();
    mToneNode = new ToneProducer();

    status_t err = roster->RegisterNode(mToneNode);
    ErrorCheck(err, "unable to register ToneProducer node!\n");
    // make sure the Media Roster knows that we're using the node
    roster->GetNodeFor(mToneNode->Node().node, &mConnection.producer);
}
Exemplo n.º 29
0
//-------------------------------------------------------------------------------------------------
UnpinnedCopyEngine::UnpinnedCopyEngine(hsa_agent_t hsaAgent, hsa_agent_t cpuAgent, size_t bufferSize, int numBuffers, 
                                       bool isLargeBar, int thresholdH2DDirectStaging, 
                                       int thresholdH2DStagingPinInPlace, int thresholdD2H) :
    _hsaAgent(hsaAgent),
    _cpuAgent(cpuAgent),
    _bufferSize(bufferSize),
    _numBuffers(numBuffers > _max_buffers ? _max_buffers : numBuffers),
    _isLargeBar(isLargeBar),
    _hipH2DTransferThresholdDirectOrStaging(thresholdH2DDirectStaging),
    _hipH2DTransferThresholdStagingOrPininplace(thresholdH2DStagingPinInPlace),
    _hipD2HTransferThreshold(thresholdD2H)
{
    hsa_amd_memory_pool_t sys_pool;
    hsa_status_t err = hsa_amd_agent_iterate_memory_pools(_cpuAgent, findGlobalPool, &sys_pool);

    // Generate a packed C-style array of agents, for use below with hsa_amd_agents_allow_access
    std::vector<hsa_agent_t> agents;
    err = hsa_iterate_agents(&find_gpu, &agents);
    ErrorCheck(err);
    hsa_agent_t * agentBlock = new hsa_agent_t[agents.size()];
    int i=0;
    for (auto iter=agents.begin(); iter!= agents.end(); iter++) {
        agentBlock[i++] = *iter;
        assert (i<=agents.size());
    };

    ErrorCheck(err);
    for (int i=0; i<_numBuffers; i++) {
        // TODO - experiment with alignment here.
        err = hsa_amd_memory_pool_allocate(sys_pool, _bufferSize, 0, (void**)(&_pinnedStagingBuffer[i]));
        ErrorCheck(err);

        if ((err != HSA_STATUS_SUCCESS) || (_pinnedStagingBuffer[i] == NULL)) {
            THROW_ERROR(hipErrorMemoryAllocation, err);
        }

        // Allow access from every agent:
        // This is used in peer-to-peer copies, since we use the buffers to copy from different agents.
        // TODO - may want to review this algorithm for NUMA locality - it might be faster to use staging buffer closer to devices?
        err = hsa_amd_agents_allow_access(agents.size(), agentBlock, NULL, _pinnedStagingBuffer[i]);
        ErrorCheck(err);

        hsa_signal_create(0, 0, NULL, &_completionSignal[i]);
        hsa_signal_create(0, 0, NULL, &_completionSignal2[i]);
    }

};
Exemplo n.º 30
0
void Window::_InitOSSurface()
{
	VkXcbSurfaceCreateInfoKHR create_info {};
	create_info.sType			= VK_STRUCTURE_TYPE_XCB_SURFACE_CREATE_INFO_KHR;
	create_info.connection		= _xcb_connection;
	create_info.window			= _xcb_window;
    ErrorCheck( vkCreateXcbSurfaceKHR( _renderer->GetVulkanInstance(), &create_info, nullptr, &_surface ) );
}