Exemplo n.º 1
0
Arquivo: ugView.c Projeto: rolk/ug
static void RefreshCommand (void)
{
  int error;
  FILE *stream;

  if (globalState!=OPENED) return;

  /* set volume */
  error = SetVol(NULL,vRefNum);
  if (((int)error)!=0)
  {
    OneButtonBox("Could not set volume","OK");
    return;
  }

  stream = fopen(fileName,"rb");
  if (stream==NULL)
  {
    OneButtonBox("Could not open file","OK");
    return;
  }

  /* draw something */
  RasterizeFile(stream,&myWindow,fx,fy);
  fclose(stream);

  DrawGrowIcon(myWindow.theWindow);
  DrawControls(myWindow.theWindow);

  return;
}
Exemplo n.º 2
0
void reply_snd_proc(void *vp, u_char *p, u_char *max, int is_up)
{
    SoundSupport *snd = (SoundSupport *)vp ;

    if (snd->next_data && !is_up) {
        DataBlock(snd,p,max) ;
        return ;
    }

    if ((max-p)>=4)
        switch (p[0])
        {
        case SNDC_CLOSE:
            if (!is_up) SndClose(snd) ;
            break ;
        case SNDC_WAVE:
            if (!is_up) WaveData(snd,p,max) ;
            break ;
        case SNDC_SETVOLUME:
            if (!is_up) SetVol(snd,p,max) ;
            break ;
        case SNDC_FORMATS:
            if (is_up) ReadFormats(snd,p,max) ;
            break ;
        default:
            break ;
        }
}
Exemplo n.º 3
0
Arquivo: ugView.c Projeto: rolk/ug
static void HDFCommand (void)
{
  SFReply reply;
  Point where;
  char prompt[128];
  OSErr error;
  char buffer[80];
  char *s;

  if (globalState!=OPENED) return;

  /* get file name */
  strcpy(buffer,"Save HDF image as:");
  strcpy(prompt,fileName);
  if ((s=strstr(prompt,".meta"))!=NULL)
    *s = '\0';
  strcat(prompt,".hdf");
  where.h = 20; where.v = 40;
  SFPutFile(where,c2pstr(buffer),c2pstr(prompt),NULL,&reply);
  if (!reply.good) return;

  /* set volume */
  error = SetVol(NULL,reply.vRefNum);
  if (((int)error)!=0)
  {
    OneButtonBox("Could not set volume","OK");
    return;
  }
  /* change pascal string to C string */
  p2cstr(reply.fName);

  RefreshCommand();
  SaveToHDF(reply.fName);
  return;
}
Exemplo n.º 4
0
void SoundSys::Load(int i_channel, string i_path, int i_loop, int i_fadein)
{
	//detect if it is the same as the former
	if (!i_path.compare(m_snds[i_channel].path))
	{
		Play(i_channel);
		return;
	}
	//if the former exists an music, unload it
	if (m_snds[i_channel].index > -1){
		Stop(i_channel, 200);
		Unload(i_channel);
	}

	//apply for the new sound
	m_snds[i_channel].channel = i_channel;
	m_snds[i_channel].loop = i_loop - 1;
	m_snds[i_channel].path = i_path;
	if (m_files->ReadRW(i_path, &(m_snds[i_channel].rw), m_snds[i_channel].index))
	{
		if (!(m_snds[i_channel].ck = Mix_LoadWAV_RW(m_snds[i_channel].rw, AUTOFREE))){
			SekaiAlert("cannot analyse the music file from " + i_path);
			return;
		}
		SetVol(i_channel, GetVol(i_channel));
		Play(i_channel, i_fadein);
	}
}
Exemplo n.º 5
0
ULONG ASMCALL
gw_SetVol( REG(d0, UWORD                    channel),
           REG(d1, Fixed                    volume),
           REG(d2, sposition                pan),
           REG(a2, struct AHIPrivAudioCtrl* audioctrl),
           REG(d3, ULONG                    flags),
           REG(a6, struct AHIBase*          AHIBase) )
{
  return SetVol( channel, volume, pan, audioctrl, flags, AHIBase );
}
Exemplo n.º 6
0
ULONG 
gw_SetVol( struct _Regs* regs )
{
  UWORD                    channel   = (UWORD)                    GET_LONG( regs->d0 );
  Fixed                    volume    = (Fixed)                    GET_LONG( regs->d1 );
  sposition                pan       = (sposition)                GET_LONG( regs->d2 );
  struct AHIPrivAudioCtrl* audioctrl = (struct AHIPrivAudioCtrl*) GET_LONG( regs->a2 );
  ULONG                    flags     = (ULONG)                    GET_LONG( regs->d3 );
  struct AHIBase*          AHIBase   = (struct AHIBase*)          GET_LONG( regs->a6 );

  return SetVol( channel, volume, pan, audioctrl, flags, AHIBase );
}
Exemplo n.º 7
0
ULONG 
gw_SetVol( void )
{
  UWORD                    channel   = (UWORD)                    REG_D0;
  Fixed                    volume    = (Fixed)                    REG_D1;
  sposition                pan       = (sposition)                REG_D2;
  struct AHIPrivAudioCtrl* audioctrl = (struct AHIPrivAudioCtrl*) REG_A2;
  ULONG                    flags     = (ULONG)                    REG_D3;
  struct AHIBase*          AHIBase   = (struct AHIBase*)          REG_A6;

  return SetVol( channel, volume, pan, audioctrl, flags, AHIBase );
}
Exemplo n.º 8
0
Arquivo: ugView.c Projeto: rolk/ug
static void OpenCommand (void)
{
  int error;
  FILE *stream;
  SFReply reply;
  Point where;
  char prompt[32];
  SFTypeList typeList;

  if (globalState==OPENED) return;

  /* get file name */
  strcpy(prompt,"choose metafile:");
  where.h = 20; where.v = 40;
  SFGetFile(where,c2pstr(prompt),NULL,-1,typeList,NULL,&reply);
  if (!reply.good)
  {
    return;
  }

  /* save name and path */
  vRefNum = reply.vRefNum;
  strcpy(fileName,p2cstr(reply.fName));

  /* set volume */
  error = SetVol(NULL,vRefNum);
  if (((int)error)!=0)
  {
    OneButtonBox("Could not set volume","OK");
    return;
  }

  stream = fopen(fileName,"rb");
  if (stream==NULL)
  {
    OneButtonBox("Could not open file","OK");
    return;
  }

  GetFileScreen(stream,&fx,&fy);

  /* open a window */
  error = CreateApplicationWindow(&myWindow,fileName,20,40,fx,fy);
  fclose(stream);
  SetState(OPENED);
  RefreshCommand();

  return;
}
Exemplo n.º 9
0
FILE *
fopen_mac ( short vRefNum , long parID , char * fileName , char * mode,
                                                char action )
{
        short oldVol ;
        short aVol ;
        long aDir , aProc ;
        FILE * ret = NULL ;

        /* change to the proper disk and directory */
  if ( GetVol ( NULL , & oldVol ) ) {
     return NULL ;
  }
  if ( GetWDInfo ( oldVol , & aVol , & aDir , & aProc ) ) {
     return NULL  ;
  }
  if ( HSetVol ( NULL , vRefNum , parID ) ) {
     return NULL ;
  }
                if( action == MAC_FOPEN_OPEN_CD || action == MAC_FOPEN_OPEN_NOCD ){
            ret = fopen ( fileName , mode ) ;
           } else{
            ret = 0;
           }

                /* this doesn't seem to work the way I want it to... */
    if( action == MAC_FOPEN_OPEN_NOCD || action == MAC_FOPEN_NOOPEN_NOCD ){
             if ( HSetVol ( NULL, aVol , aDir ) ) {
                /* an error we can't currently handle */
            }
            if ( SetVol ( NULL, oldVol ) ) {
        /* an error we can't currently handle */
            }
    }
    return ret ;
}
Exemplo n.º 10
0
char *macFindFile(char *fileName, Str255 message, Str255 defaultname,
			  Integer readWrite, Integer ntypes, OSType * types, 
			  Integer * volume) 
{
	SFTypeList      myTypes;
	Point           p;
	Integer         numTypes;
	Integer         vRefNum = (volume != (Integer *) 0) ? *volume : 0;
	LongInt         dirID;
	int             i;
	WHERE("macFindFile");

	if (fileName[0] == '\0')
	{
		/* Use standard file dialog box */
		SetPt(&p, 82, 90);
	
		DeactivateWindow();		/*unhighlight front window*/

		if (readWrite == WRITEIT)
		{						/* write */
			DialogEdit = true;
			NDialogButtons = 2;
			ButtonChars[0] = 's';
			ButtonChars[1] = 'n';
			SFPPutFile(p, message, defaultname, NullDialogHookPtr, &Reply,
					   putDlgID, MyDialogFilterPtr);
		} /*if (readWrite == WRITEIT)*/
		else
		{/* read */
			if(ntypes == 0)
			{
				numTypes = 0;
				myTypes[numTypes++] = 'TEXT';
				myTypes[numTypes++] = 'ttro';
				if(types != (OSType *) 0)
				{
					myTypes[numTypes++] = types[0];
				}
			}
			else
			{
				numTypes = (ntypes <= 4) ? ntypes : 4; /*play it safe*/
				for(i = 0;i < numTypes; i++)
				{
					myTypes[i] = types[i];
				}
			}
			DialogEdit = false;
			NDialogButtons = 2;
			ButtonChars[0] = 'o'; /* Open */
			ButtonChars[1] = 'n'; /* Cancel */
			SFPGetFile(p, message, NullFileFilterPtr,	
					   numTypes, myTypes, NullDialogHookPtr, &Reply,
					   getDlgID, MyDialogFilterPtr);
		} /*if (readWrite == WRITEIT){}else{}*/
		macUpdate((WindowPtr) 0);
	
		if (!Reply.good)
		{ /* cancelled */
			return (0);
		}
		vRefNum = Reply.vRefNum;
		if (volume != (Integer *) 0)
		{
			*volume = vRefNum;
		}
	
		PtoCstr((unsigned char *) Reply.fName);
		strcpy(FileName, (char *) Reply.fName);
		CtoPstr((char *) Reply.fName);
		fileName = FileName;
	} /*if (fileName[0] == '\0')*/
	else if (volume != (Integer *) 0 && vRefNum == 0 &&
			 HGetVol((StringPtr) 0, &vRefNum, &dirID) == noErr)
	{
		*volume = vRefNum;
	}
 
	if (vRefNum != 0)
	{
		SetVol(0L, vRefNum);
	}
	return (fileName);

} /*macFindFile()*/
AudioHandle AudioManagerSDL::Play( string fName, bool bLooping /*= false*/, bool bIsMusic, bool bAddBasePath, bool bForceStreaming)
{

#ifdef _DEBUG
	//LogMsg("********** AudioSDL: Thinking of playing %s, music=%d", fName.c_str(), int(bIsMusic));
#endif

	if (!GetSoundEnabled() && !bIsMusic) return AUDIO_HANDLE_BLANK;
	if (!GetMusicEnabled() && bIsMusic)
	{
		m_bLastMusicLooping = bLooping;
		m_lastMusicFileName = fName;

		return AUDIO_HANDLE_BLANK;
	}

	if (bIsMusic && m_bLastMusicLooping == bLooping && m_lastMusicFileName == fName && m_bLastMusicLooping && IsPlaying((AudioHandle) m_pMusicChannel))
	{
		return (AudioHandle) m_pMusicChannel;
	}

	int loops = 0;
	if (bLooping) loops = -1;

	if (bIsMusic)
	{
		string basePath;

		if (bAddBasePath)
		{
			basePath = GetBaseAppPath();
		}

		m_lastMusicFileName = fName;

		StopMusic();
		m_pMusicChannel = Mix_LoadMUS( (basePath+fName).c_str());

		if (!m_pMusicChannel && !bAddBasePath)
		{
			LogError("Couldn't load %s, trying again with full path", (basePath+fName).c_str());

			basePath = GetBaseAppPath();
			//try again with the basepath added.. the SDL sound system on webos seems to require it
			m_pMusicChannel = Mix_LoadMUS((basePath+fName).c_str());
		}

		if (!m_pMusicChannel)
		{
			LogError("Unable to load music file %s. Missing?", (basePath+fName).c_str());
			return AUDIO_HANDLE_BLANK;
		}
		m_lastMusicID = (AudioHandle) m_pMusicChannel;
		m_bLastMusicLooping = bLooping;
		
		SetMusicVol(m_musicVol);

		int ret = Mix_PlayMusic(m_pMusicChannel, loops);
		if (ret == -1)
		{
			LogError("Unable to play music file %s.", (GetBaseAppPath()+fName).c_str());
		}

		return (AudioHandle) m_pMusicChannel;
	}

	//non music

	SoundObject *pObject = GetSoundObjectByFileName(fName);

	if (!pObject)
	{
		//create it
		Preload(fName, bLooping, bIsMusic, bAddBasePath, bForceStreaming);
		pObject = GetSoundObjectByFileName(fName);
		if (!pObject)
		{
			LogError("Unable to cache sound %s", fName.c_str());
			return AUDIO_HANDLE_BLANK;

		}
	}

#ifdef _DEBUG
	//LogMsg("AudioSDL: Playing sfx %s", fName.c_str());
#endif

	//play it
	
	int channel = Mix_PlayChannel(-1, pObject->m_pSound, loops);
	if (channel == -1)
	{
		pObject->m_pLastChannelToUse = AUDIO_HANDLE_BLANK;
		return AUDIO_HANDLE_BLANK;
	}
	pObject->m_pLastChannelToUse = channel + C_CHANNEL_OFFSET_SO_ZERO_ISNT_USED;

	//need this because sometimes it's set to nothing by default??
	SetVol(pObject->m_pLastChannelToUse, 1.0f);

	return (AudioHandle)pObject->m_pLastChannelToUse ;
}
Exemplo n.º 12
0
void
open_game(Str255 name, int vrefnum)
{
	SetVol(nil, vrefnum);
	imfapp_main();
}