Play FLAC songs with Datatypes

This forum is for general developer support questions.
Post Reply
User avatar
mritter0
Posts: 214
Joined: Mon Aug 25, 2014 9:41 pm
Location: Bettendorf, IA, USA

Play FLAC songs with Datatypes

Post by mritter0 »

I am adding support to play FLAC song files in my project. I use this code to play MP3s, but it will not play FLACs

Code: Select all

if ((SoundObject=IDataTypes->NewDTObject(SoundPath,
	DTA_GroupID,						GID_SOUND,
TAG_END)))
{
	PreviewSoundSignal=IExec->AllocSignal(-1);

	IDataTypes->SetDTAttrs(SoundObject,MainWindow,NULL,
		SDTA_SignalTask,					IExec->FindTask(NULL),
		SDTA_SignalBitMask,					1L << PreviewSoundSignal,
	TAG_DONE);

	IDataTypes->DoDTMethod(SoundObject,NULL,NULL,DTM_TRIGGER,NULL,STM_PLAY,NULL);
	SoundPlaying=TRUE;
}
It fails at the NewDTObject() function. The FLACs are being identified as 'Sound' (why aren't MP3s and FLACs considered 'Music'?). I also tried GID_MUSIC, same result.

MultiViewer will play the FLACs.

Any ideas?
Workbench Explorer - A better way to browse drawers

User avatar
broadblues
AmigaOS Core Developer
AmigaOS Core Developer
Posts: 591
Joined: Sat Jun 18, 2011 2:40 am
Location: Portsmouth, UK
Contact:

Re: Play FLAC songs with Datatypes

Post by broadblues »

mritter0 wrote: MultiViewer will play the FLACs.

Any ideas?
Easy one first, GID_MUSIC refers to a score, tab or other representation of the music, perhaps midi, though in reality midi datatypes are usually GID_SOUND. There isn't a base class for GID_MUSIC at the current time. If there wwere it would likely *display* the score so a musician could read and play it.

IN terms of why music files are soundf iles, there is no meaningful difference between the sound of a rock being banged repeatedly in rhythm and the sound of a landslide, except in the human brain. :-)

Here's my sound player from AOrganiser. Note that I set the src type explicitly and a few other settigs.
I don't have any FLACS to test with or a FLAC datatype installed for that matter.

Code: Select all

        case ALARM_SOUND:
        {
        	if(al->al_Data.al_Sound.al_SoundFile)
        	{
        		/* skip alarm if we are playing one! */
        		/* at the moment we are single process so thos should be all we need */
				/* if we add multi tasking then a semaphore might be required */
				
        		if(!diary->dd_CurrentSound)
        		{
        			
        			diary->dd_CurrentSound  = IDataTypes->NewDTObject(al->al_Data.al_Sound.al_SoundFile,
        						DTA_SourceType,DTST_FILE,
        						DTA_GroupID, GID_SOUND,
        						SDTA_Volume,64,
        						SDTA_Cycles,1,
        						SDTA_SignalTask, IExec->FindTask(NULL),
        						SDTA_SignalBitNumber,SIGBREAKB_CTRL_F,
        					TAG_DONE);
	        		if(diary->dd_CurrentSound)
    	    		{
        				struct dtTrigger dtt = {0};
        				
        				dtt.MethodID = DTM_TRIGGER;
        				dtt.dtt_GInfo = NULL;
        				dtt.dtt_Function = STM_PLAY;
        				dtt.dtt_Data = NULL;
        				
        				IIntuition->IDoMethodA(diary->dd_CurrentSound,(Msg)&dtt);
        				
        			}
        		}
        	}
        	break;
        }
My main loop waits for the signal.

Code: Select all

				                            if(sig & SIGBREAKF_CTRL_F)
				                            {
				                            	/* the sound we were playing stopped */
				                            	if(diary->dd_CurrentSound)
				                            	{
				                            		IDataTypes->DisposeDTObject(diary->dd_CurrentSound);
				                            		diary->dd_CurrentSound = NULL;
				                            	}
				                             
			    	                        }

User avatar
mritter0
Posts: 214
Joined: Mon Aug 25, 2014 9:41 pm
Location: Bettendorf, IA, USA

Re: Play FLAC songs with Datatypes

Post by mritter0 »

I got up in the middle of the night. Added in DTA_SourceType,DTST_FILE, it works now. Must need that little extra kick.
Workbench Explorer - A better way to browse drawers

Post Reply