Author Topic: [SOLVED] how to add a soundfiles to layout / play sounds  (Read 19803 times)

hermine.potter

  • Hero Member
  • *****
  • Posts: 767
    • View Profile
[SOLVED] how to add a soundfiles to layout / play sounds
« on: May 28, 2015, 06:26:42 AM »
Hi!
I'm trying adding soundfiles to a layout (especially a die-sound of attracman in attracman-layout). squirrel isn't my language yet. I've found the play-function, but wasn't able playing the soundfile yet. Please help ^-^

I've found pacman-soundfiles there.., copy the death1.wav to layouts/attracman and added this extra phrases on line #1257 in layouts/attracman/engine.nut

::pman.death ( animate_frame );
//declare
local death_sound = fe.add_sound ( "death1.wav" );
//execute
death_sound.playing=true;

g.collided = false;
« Last Edit: May 29, 2015, 03:48:54 AM by hermine.potter »
AM Version : 2.6.1
Input : Mad Catz Brawlstick; Mouse; Keyboard; Xbox360 Wireless
Cabinet : Yes
OS : Windows10 Pro
System : Dell Precision T3500 ; Intel X5650 ; 12GB RAM

atrfate

  • Full Member
  • ***
  • Posts: 86
    • View Profile
Re: how to add a soundfiles to layout / play sounds
« Reply #1 on: May 28, 2015, 10:57:39 AM »
Depends on when you want them to play for instance
Code: [Select]
function transition_callback(ttype, var, ttime)
{
    switch ( ttype )
    {
        case Transition.StartLayout:
case Transition.ToNewSelection:
                 local Wheelclick = fe.add_sound("Click.mp3")
Wheelclick.playing=true
            break;
    }
    return false;
This will make a wheel click sound play when you select a game to a new selection, but if you want the death sound to play when you say press up you need to look into Sig

atrfate

  • Full Member
  • ***
  • Posts: 86
    • View Profile
Re: how to add a soundfiles to layout / play sounds
« Reply #2 on: May 28, 2015, 11:06:52 AM »
After looking semi into what you where asking I think your trying to play a sound when when the pacman dies in the attrachman theme only inside the engine.nut file you should find
   
Code: [Select]
g.animate( animate_frame );

if ( g.collided == true )
{
if (( ::pman.die == 0 )
&& ( g.gstate == GhostState.Frightened ))
{
g.eaten( animate_frame, ::eat_count );
::eat_count++;
::pman.obj.visible = false;
::last_frame += 50; // 1 second global pause
}
else if (( g.gstate == GhostState.Chase )
|| ( g.gstate == GhostState.Scatter ))
::pman.death( animate_frame );
        [b]local Wheelclick = fe.add_sound("Click.mp3")
                     Wheelclick.playing=true[/b]

g.collided = false;
}
}
change the soundfile to yours and your good to go

hermine.potter

  • Hero Member
  • *****
  • Posts: 767
    • View Profile
Re: how to add a soundfiles to layout / play sounds
« Reply #3 on: May 28, 2015, 10:52:58 PM »
Thank you for confirming my code-snippet (it's the same. I used death_sound instead Wheelclick as variable ^-^).

I've found a solution. I've copied the death1.wav to the root of AM (where attract.exe is found).
In my case: C:\attract

Now attracman dies with the pacman death soundfile. Please notice that attracman is only a cousin of pacman ^-^

Is it possible, adding a path to file? This doesn't work:
local Wheelclick = fe.add_sound("C:\attract\sounds\Click.mp3")
=> unrecognised escaper char

AM Version : 2.6.1
Input : Mad Catz Brawlstick; Mouse; Keyboard; Xbox360 Wireless
Cabinet : Yes
OS : Windows10 Pro
System : Dell Precision T3500 ; Intel X5650 ; 12GB RAM

atrfate

  • Full Member
  • ***
  • Posts: 86
    • View Profile
Re: how to add a soundfiles to layout / play sounds
« Reply #4 on: May 29, 2015, 03:04:52 AM »
I haven't ever found a way to do paths with the soundfiles, should have mentioned that they have to be in root :P i added clicks during game selections thats why it was wheel click

hermine.potter

  • Hero Member
  • *****
  • Posts: 767
    • View Profile
Re: how to add a soundfiles to layout / play sounds
« Reply #5 on: May 29, 2015, 03:46:36 AM »
thank you and never mind. that's ok. now i'm able to playing soundfiles and that's the clou ^-^

first time putted on the folder of attracman-layout and it doesn't worked
(as told as in the reference : fe.add_sound( name )
name - the name of the sound file located in the layout directory.

next putted on sounds-folder and doesnt't worked

puttend on root => perfect. play sounds ^-^
learning by doing..
« Last Edit: May 29, 2015, 03:51:48 AM by hermine.potter »
AM Version : 2.6.1
Input : Mad Catz Brawlstick; Mouse; Keyboard; Xbox360 Wireless
Cabinet : Yes
OS : Windows10 Pro
System : Dell Precision T3500 ; Intel X5650 ; 12GB RAM

liquid8d

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 442
    • View Profile
Re: how to add a soundfiles to layout / play sounds
« Reply #6 on: May 29, 2015, 11:52:50 AM »
I haven't ever found a way to do paths with the soundfiles, should have mentioned that they have to be in root :P i added clicks during game selections thats why it was wheel click

That is weird.. maybe a bug - it should be relative to the layout or using fe.script_dir should work. Looks like you can do this though:

local arcade = fe.add_sound(FeConfigDirectory + "/layouts/my_layout/arcade.mp3");

checkist

  • Jr. Member
  • **
  • Posts: 22
    • View Profile
Re: [SOLVED] how to add a soundfiles to layout / play sounds
« Reply #7 on: May 30, 2015, 04:58:50 AM »
local Wheelclick = fe.add_sound("C:\attract\sounds\Click.mp3")
=> unrecognised escaper char

Seems very familiar issue that single '\' is treated as escape character...

Does

local Wheelclick = fe.add_sound("C:\\attract\\sounds\\Click.mp3")

work?

raygun

  • Administrator
  • Sr. Member
  • *****
  • Posts: 393
    • View Profile
Re: how to add a soundfiles to layout / play sounds
« Reply #8 on: May 30, 2015, 09:16:54 PM »
thank you and never mind. that's ok. now i'm able to playing soundfiles and that's the clou ^-^

first time putted on the folder of attracman-layout and it doesn't worked
(as told as in the reference : fe.add_sound( name )
name - the name of the sound file located in the layout directory.

next putted on sounds-folder and doesnt't worked

puttend on root => perfect. play sounds ^-^
learning by doing..

Hi there,

My intention was to put sounds in attracman, but I never finished the job!  Good to see you've got it going.  I checked the code, and you've definitely uncovered a bug in Attract-Mode's add_sound() function, so I'll fix that for the next version to behave as documented =)

cheers

p.s. I'm pretty sure checkist has it right, if you are doing backslash paths in squirrel you have double up so "c:\\games\\"... alternatively it will work with single forward slashes "c:/games/"...
« Last Edit: May 30, 2015, 09:19:02 PM by raygun »

hermine.potter

  • Hero Member
  • *****
  • Posts: 767
    • View Profile
Re: [SOLVED] how to add a soundfiles to layout / play sounds
« Reply #9 on: June 03, 2015, 12:42:53 AM »
aah! escape characters, of course!
Thank you. It works.

local death_sound = fe.add_sound ( "C:\\attract\\sounds\\death1.wav" );
death_sound.playing=true;
AM Version : 2.6.1
Input : Mad Catz Brawlstick; Mouse; Keyboard; Xbox360 Wireless
Cabinet : Yes
OS : Windows10 Pro
System : Dell Precision T3500 ; Intel X5650 ; 12GB RAM

hermine.potter

  • Hero Member
  • *****
  • Posts: 767
    • View Profile
Re: [SOLVED] how to add a soundfiles to layout / play sounds
« Reply #10 on: March 03, 2016, 10:19:14 PM »
UPDATE:
I've lose sight on entering pacman-sounds in AttracMan-layout.
Yesterday, I've tested AM 2.0.0 RC2 intent entering the death-sound-file.
You did it already and now very easy by layout-options ^-^ Thank you so much :-)

Steps:
1) copy Soundfiles on AM_Folder\layouts\Attrac-Man (or another folder)
2) start AM
3) Displays > your_emulator_display > Layout Options > Death Sound : name_of_your_death_sound_file    or    path_to_your_sound_files\name_of_your_death_sound_file

[SOLVED]
« Last Edit: March 03, 2016, 10:23:09 PM by hermine.potter »
AM Version : 2.6.1
Input : Mad Catz Brawlstick; Mouse; Keyboard; Xbox360 Wireless
Cabinet : Yes
OS : Windows10 Pro
System : Dell Precision T3500 ; Intel X5650 ; 12GB RAM