View unanswered posts | View active topics It is currently Thu Jul 18, 2019 6:47 am



Reply to topic  [ 136 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6  Next
Linux/FreeBSD/Mac OS X etc sound 

Best audio API
SDL 20%  20%  [ 10 ]
AO 20%  20%  [ 10 ]
OpenAL 29%  29%  [ 14 ]
Semi Portable OSS 12%  12%  [ 6 ]
Non Portable ALSA 10%  10%  [ 5 ]
Non Portable CoreAudio 2%  2%  [ 1 ]
Other 6%  6%  [ 3 ]
Total votes : 49

Linux/FreeBSD/Mac OS X etc sound 
Author Message
Rookie

Joined: Mon Oct 10, 2005 12:02 pm
Posts: 21
Reply with quote
Post 
I need to add that changing samplerate while running zsnes will require a restart for the device to get set... sounds like an easy fix tho...


Mon Mar 20, 2006 12:40 pm
Profile
ZSNES Developer
ZSNES Developer
User avatar

Joined: Tue Jul 27, 2004 10:54 pm
Posts: 3901
Location: Solar powered park bench
Reply with quote
Post 
Spike wrote:
I got it working on my emu10k1.

I didn't :(

Spike wrote:
if (ioctl(fdAudio, SNDCTL_DSP_SETFRAGMENT, "32") == -1)
fprintf(stderr, "Could not set PCM format on device.\n");

fragment size should be set to something sensible...

if (ioctl(fdAudio, SNDCTL_DSP_SPEED, &oss_samplerate) == -1)
fprintf(stderr, "Could not set PCM format on device.\n");

and of course set the samplerate!

That makes it better for me, but it still sounds terrible.

_________________
May 9 2007 - NSRT 3.4, now with lots of hashing and even more accurate information! Go download it.
_____________
Insane Coding


Mon Mar 20, 2006 12:43 pm
Profile WWW
Rookie

Joined: Mon Oct 10, 2005 12:02 pm
Posts: 21
Reply with quote
Post 
Code:
    printf("Sample: %d\n", oss_samplerate);

        if (!AudioOpen)         

        if ((fdAudio = open("/dev/dsp",  O_WRONLY, 0)) == -1)
        fprintf(stderr, "Error opening /dev/dsp\n");

        if (ioctl(fdAudio, SNDCTL_DSP_SETFMT, &oss_format) == -1)
        fprintf(stderr, "Could not set DSP SETFMT on device.\n");

        AudioOpen = 1;

        ioctl(fdAudio, SNDCTL_DSP_RESET, 0);

        if (ioctl(fdAudio, SNDCTL_DSP_SETFRAGMENT, "32") == -1)
        fprintf(stderr, "Could not set DSP FRAGMENT format on device.\n");

        if (ioctl(fdAudio, SNDCTL_DSP_SPEED, &oss_samplerate) == -1)
        fprintf(stderr, "Could not set DSP SPEED on device.\n");

        if (ioctl(fdAudio, SNDCTL_DSP_CHANNELS, &oss_channels) == -1)
        fprintf(stderr, "Could not set DSP CHANNELS on device.\n");

        if (ioctl(fdAudio, SNDCTL_DSP_SYNC, 0) == -1)
        fprintf(stderr, "Could not set DSP SYNC on device.\n");

        if (ioctl (fdAudio, SNDCTL_DSP_NONBLOCK, &blah) < 0)
        fprintf(stderr, "Could not set DSP NONBLOCK on device.\n");

  ntschi = SAMPLE_NTSC_HI_SCALE*oss_samplerate;



Fixes that issue... samplerate changes when i command it to now

Nach wrote:
Spike wrote:
I got it working on my emu10k1.

I didn't :(

Spike wrote:
if (ioctl(fdAudio, SNDCTL_DSP_SETFRAGMENT, "32") == -1)
fprintf(stderr, "Could not set PCM format on device.\n");

fragment size should be set to something sensible...

if (ioctl(fdAudio, SNDCTL_DSP_SPEED, &oss_samplerate) == -1)
fprintf(stderr, "Could not set PCM format on device.\n");

and of course set the samplerate!

That makes it better for me, but it still sounds terrible.


Which soundchip do you have? Seems not all soundchips respond to OSS commands as properly as others. So this may work some cards, but not others. :(

Just needs more work.

EDIT: emu10k1, nm... odd
Difference may be in using plain OSS drivers and that ALSA OSS junk.... :|
They seem to not comply too well with OSS standards...

I'm wondering if that SNDCTL_DSP_SYNC is really useful...

damnit, SETFMT shouldnt be set more then once...

Code:
        if (!AudioOpen)         

        if ((fdAudio = open("/dev/dsp",  O_WRONLY, 0)) == -1)
        fprintf(stderr, "Error opening /dev/dsp\n");

        if (!AudioOpen)

        if (ioctl(fdAudio, SNDCTL_DSP_SETFMT, &oss_format) == -1)
        fprintf(stderr, "Could not set DSP SETFMT on device.\n");

        AudioOpen = 1;


Yes, laugh at me, i'm just learning still. :P

Meh, best way to do this would be to reset then close, then reopen the device, and then set the parameters.


Mon Mar 20, 2006 12:56 pm
Profile
Rookie

Joined: Mon Oct 10, 2005 12:02 pm
Posts: 21
Reply with quote
Post 
Alright....

Code:
    printf("Sample: %d\n", oss_samplerate);

        if (fdAudio)
        {
                ioctl(fdAudio, SNDCTL_DSP_RESET, 0);
                close(fdAudio);
        }

        if ((fdAudio = open("/dev/dsp",  O_WRONLY, 0)) == -1)
        fprintf(stderr, "Error opening /dev/dsp\n");

        if (ioctl(fdAudio, SNDCTL_DSP_SETFMT, &oss_format) == -1)
        fprintf(stderr, "Could not set DSP SETFMT on device.\n");

        if (ioctl(fdAudio, SNDCTL_DSP_SETFRAGMENT, "32") == -1)
        fprintf(stderr, "Could not set DSP FRAGMENT on device.\n");

        if (ioctl(fdAudio, SNDCTL_DSP_SPEED, &oss_samplerate) == -1)
        fprintf(stderr, "Could not set DSP SPEED on device.\n");

        if (ioctl(fdAudio, SNDCTL_DSP_CHANNELS, &oss_channels) == -1)
        fprintf(stderr, "Could not set DSP CHANNELS on device.\n");

        if (ioctl(fdAudio, SNDCTL_DSP_SYNC, &blah) == -1)
        fprintf(stderr, "Could not set DSP SYNC on device.\n");

        if (ioctl (fdAudio, SNDCTL_DSP_NONBLOCK, &blah) < 0)
        fprintf(stderr, "Could not set DSP NONBLOCK on device.\n");

  ntschi = SAMPLE_NTSC_HI_SCALE*oss_samplerate;



I know it works for me, I just wish I had some more lesser crappy soundcard to do further testing with. I know OSS a small bit, as I been hacking around the OSS code for Audacious media player alot lately figuring out what what does and managed to get real gapless playback going as well.


Mon Mar 20, 2006 1:18 pm
Profile
ZSNES Developer
ZSNES Developer
User avatar

Joined: Tue Jul 27, 2004 10:54 pm
Posts: 3901
Location: Solar powered park bench
Reply with quote
Post 
Spike wrote:
EDIT: emu10k1, nm... odd
Difference may be in using plain OSS drivers and that ALSA OSS junk.... :|
They seem to not comply too well with OSS standards...

I do use OSS.

BTW thanks for your help, using your suggestions, I got it working perfectly for me :D

Code:
int fdAudio = 0;
int oss_format = AFMT_S16_LE;
int InitSound(void)
{
  const int freqtab[7] = { 8000, 11025, 22050, 44100, 16000, 32000, 48000 };
  int oss_channels = 2;
  int oss_samplerate = freqtab[SoundQuality];
  int blah = 1;


  printf("Sample: %d\n", oss_samplerate);

  if (fdAudio)
  {
    ioctl(fdAudio, SNDCTL_DSP_RESET, 0);
    close(fdAudio);
  }

  if ((fdAudio = open("/dev/dsp",  O_WRONLY, 0)) == -1)
  fprintf(stderr, "Error opening /dev/dsp\n");

  if (ioctl(fdAudio, SNDCTL_DSP_SETFMT, &oss_format) == -1)
  fprintf(stderr, "Could not set DSP SETFMT on device.\n");

  if (ioctl(fdAudio, SNDCTL_DSP_SETFRAGMENT, "32") == -1)
  fprintf(stderr, "Could not set DSP FRAGMENT on device.\n");

  if (ioctl(fdAudio, SNDCTL_DSP_SPEED, &oss_samplerate) == -1)
  fprintf(stderr, "Could not set DSP SPEED on device.\n");

  if (ioctl(fdAudio, SNDCTL_DSP_CHANNELS, &oss_channels) == -1)
  fprintf(stderr, "Could not set DSP CHANNELS on device.\n");

  if (ioctl(fdAudio, SNDCTL_DSP_SYNC, &blah) == -1)
  fprintf(stderr, "Could not set DSP SYNC on device.\n");

  if (ioctl (fdAudio, SNDCTL_DSP_NONBLOCK, &blah) < 0)
  fprintf(stderr, "Could not set DSP NONBLOCK on device.\n");

  ntschi = SAMPLE_NTSC_HI_SCALE*oss_samplerate;
  ntsclo = SAMPLE_NTSC_LO;
  ntscbalance = ntschi;

  if (!SoundEnabled)
  {
      return FALSE;
  }

  PrevSoundQuality = SoundQuality;
  PrevStereoSound = StereoSound;

  if (SoundQuality > 6)
      SoundQuality = 1;

    return TRUE;
}

No more crackling or popping during ToP :D

Although I notice the emulators slows down at some parts where it can't get the audio out.

_________________
May 9 2007 - NSRT 3.4, now with lots of hashing and even more accurate information! Go download it.
_____________
Insane Coding


Mon Mar 20, 2006 1:29 pm
Profile WWW
Rookie

Joined: Mon Oct 10, 2005 12:02 pm
Posts: 21
Reply with quote
Post 
Yup, I'm almost sure thats related to the 100% cpu gremlin I was talking about.

I'm not sure if its related to the OSS code or something recently changed in CVS however. As it only happens during emulation, and the OSS stuff happens upon load, where the issue isnt existant.

Glad it worked for you however!


Mon Mar 20, 2006 1:34 pm
Profile
Rookie

Joined: Mon Oct 10, 2005 12:02 pm
Posts: 21
Reply with quote
Post 
AND YES, NO MORE DARN CRACKLING! :D


Mon Mar 20, 2006 1:43 pm
Profile
ZSNES Developer
ZSNES Developer
User avatar

Joined: Tue Aug 17, 2004 5:24 am
Posts: 812
Location: In your garden
Reply with quote
Post 
Ah nice, I get back and everything is done :P

Thanks for your help :)

These changes work very well so far for everyone who has tested them. I guess what is left is to add support for PAL roms and probably do ALSA support. Also I guess I have to implement the ReInitSound function so you don't have to keep restarting the client.

The CPU usage is a result of removal of the semaphore code, it will go back in again. I just took it out for debugging.


Mon Mar 20, 2006 2:12 pm
Profile
ZSNES Developer
ZSNES Developer
User avatar

Joined: Tue Jul 27, 2004 10:54 pm
Posts: 3901
Location: Solar powered park bench
Reply with quote
Post 
http://nsrt.edgeemu.com/sdllink.c

Now supports all rates, PAL, and mono sound too.
Sound reinit seems to work good too :D

I also cleaned up some of the code and made it get the audio out faster, no more slow downs for me :)

_________________
May 9 2007 - NSRT 3.4, now with lots of hashing and even more accurate information! Go download it.
_____________
Insane Coding


Mon Mar 20, 2006 2:55 pm
Profile WWW
Rookie

Joined: Mon Oct 10, 2005 12:02 pm
Posts: 21
Reply with quote
Post 
Looking great, and sounds great too.

Minor issue of disable sound tickbox not working yet though, for the picky.

Not that I ever use the disable sound feature. :-)

EDIT: nm, dont seem like the code there to look from cfgsoundon exists yet. WIP!

Heh, I tried but seems how it is if I even change SoundEnabled=1 to 0, i get the dreaded FP exception.

I did manage to get the actual config part read however, but that only needs an extern BYTE variable for cfgsoundon set and a way for it to reassign SoundEnabled.

Oh well, FP exceptions are a little over my head at this point in time.


Mon Mar 20, 2006 5:15 pm
Profile
ZSNES Developer
ZSNES Developer
User avatar

Joined: Tue Jul 27, 2004 10:54 pm
Posts: 3901
Location: Solar powered park bench
Reply with quote
Post 
I know the problem, I'll fix it later, basically just need to skip sound output if sound is off.

_________________
May 9 2007 - NSRT 3.4, now with lots of hashing and even more accurate information! Go download it.
_____________
Insane Coding


Mon Mar 20, 2006 6:07 pm
Profile WWW
Rookie

Joined: Mon Oct 10, 2005 12:02 pm
Posts: 21
Reply with quote
Post 
Nach wrote:
I know the problem, I'll fix it later, basically just need to skip sound output if sound is off.


You the man!

Cheers.


Mon Mar 20, 2006 6:28 pm
Profile
Rookie

Joined: Mon Oct 10, 2005 12:02 pm
Posts: 21
Reply with quote
Post 
Finally Super Mario World no longer sounds like SH*T!


Mon Mar 20, 2006 10:11 pm
Profile
ZSNES Developer
ZSNES Developer
User avatar

Joined: Tue Aug 17, 2004 5:24 am
Posts: 812
Location: In your garden
Reply with quote
Post 
Updates:

No longer uses 100% CPU
Now syncs video to audio.
Checks to see if your card supports reporting the sound output delay.
Minor code cleanups.

http://zsnes.game-host.org/~pagefault/sdllink.c

Update #2

http://zsnes.game-host.org/~pagefault/synctest.c

Try this as well, this does a lot better job syncing the sound but also uses more CPU. May be an option later on.


Thu Mar 23, 2006 5:03 am
Profile
Rookie

Joined: Mon Oct 10, 2005 12:02 pm
Posts: 21
Reply with quote
Post 
Testing them now, heh.

First one works great, second one hangs at 100% cpu at the start of emulation.


Thu Mar 23, 2006 12:17 pm
Profile
ZSNES Developer
ZSNES Developer
User avatar

Joined: Tue Jul 27, 2004 10:54 pm
Posts: 3901
Location: Solar powered park bench
Reply with quote
Post 
First one is still desynced for me, and seems to have slower fast foward.

Second is synced but brings it all to a crawl, and fast foward is just dead.

_________________
May 9 2007 - NSRT 3.4, now with lots of hashing and even more accurate information! Go download it.
_____________
Insane Coding


Thu Mar 23, 2006 3:52 pm
Profile WWW
ZSNES Developer
ZSNES Developer
User avatar

Joined: Tue Aug 17, 2004 5:24 am
Posts: 812
Location: In your garden
Reply with quote
Post 
The high CPU usage is normal for the second one. It tries to sync as accurately as possible while the first one does an "alright" job syncing. There will probably be an option for the more aggressive syncing later on for people who want it, although it shouldn't lock up your system. I will check into that.


Thu Mar 23, 2006 8:35 pm
Profile
Rookie

Joined: Mon Oct 10, 2005 12:02 pm
Posts: 21
Reply with quote
Post 
It doesn't lockup my system at all, but zsnes becomes frozen in a 100% cpu coma until I killall -9 it.


Fri Mar 24, 2006 12:30 pm
Profile
Reply with quote
Post 
Hello

What must we do with the file sdllink.c ? how install it ?

Thanks !

PS : Excuse my english !

I'm on Ubuntu dapper with Zsnes ver. 1.420-0.1ubuntu1 (also 1.42)


Wed Mar 29, 2006 9:10 pm
New Member

Joined: Thu Mar 30, 2006 10:20 pm
Posts: 4
Reply with quote
Post 
I am using the ZSNESW_0329 and perceived that he has a problem in the audio, some type of noise intermittent in back sound. I have a Audigy ZS2.


Sat Apr 01, 2006 6:07 pm
Profile
Veteran
User avatar

Joined: Thu Feb 03, 2005 8:18 pm
Posts: 768
Reply with quote
Post 
Max_Fire wrote:
I am using the ZSNESW_0329 and perceived that he has a problem in the audio, some type of noise intermittent in back sound. I have a Audigy ZS2.

Please do not post about the same thing in two different places. If we know the answer to the problem, we will tell you. Posting more times about the same thing does not increase your chances of getting an answer.

_________________
Official ZSNES Docs | NSRT Guide | Using a Wiimote w/ emulators


Sat Apr 01, 2006 8:36 pm
Profile WWW
ZSNES Developer
ZSNES Developer
User avatar

Joined: Tue Aug 17, 2004 5:24 am
Posts: 812
Location: In your garden
Reply with quote
Post 
This is not related to the SDL port at all either.


Sun Apr 02, 2006 3:40 am
Profile
Rookie

Joined: Tue Apr 25, 2006 4:30 am
Posts: 11
Reply with quote
Post 
This is a great idea! If this is still in progress libao would be a good reference as it's extremely small and fairly clean. People say good things about OpenAL too. Most anything is better than the high latencies and poor quality of SDL sound. I voted ALSA - please code an mmap() mode too!


Tue Apr 25, 2006 4:53 am
Profile
New Member

Joined: Tue Apr 25, 2006 11:34 am
Posts: 3
Location: Netherlands, Enschede
Reply with quote
Post 
I tested it with my ENS1371. I was able to get it to work with aoss for one session. It worked extemely well. It somehow now doesn't work anymore through aoss though.
When I use the kernel OSS emulation, the emulated devices seem to miss several needed features.

I'm really looking forward to a native ALSA version :)


Tue Apr 25, 2006 9:09 pm
Profile ICQ WWW
New Member

Joined: Wed May 03, 2006 12:14 am
Posts: 5
Reply with quote
Post 
pagefault wrote:
Updates:

No longer uses 100% CPU
Now syncs video to audio.
Checks to see if your card supports reporting the sound output delay.
Minor code cleanups.

http://zsnes.game-host.org/~pagefault/sdllink.c

Update #2

http://zsnes.game-host.org/~pagefault/synctest.c

Try this as well, this does a lot better job syncing the sound but also uses more CPU. May be an option later on.
My roommate and I just found out that the third roommate in our group has never played Secret of Mana. (*shock!*) So I'm going to be re-installing ZSNES today and starting up a game.

I just recently moved to Linux after kicking my Warcraft habit, so I'm wondering if there is anything I need to do to get ALSA goodness working when installing ZSNES. Are these updates included in ZSNES 1.42? Or do I need to download the c files from pagefault's web site and override the originals when compiling?

Just wondering. Thanks!


Wed May 03, 2006 12:21 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 136 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6  Next

Who is online

Users browsing this forum: No registered users and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software.