PS2 OPL SND TEST

Discussion in 'Open PS2 Loader (OPL)' started by Krah, Aug 11, 2018.

Thread Status:
Not open for further replies.
  1. 191
    271
    122
    Krah

    Krah Developer

    Joined:
    Jul 20, 2018
    Messages:
    191
    Likes Received:
    271
    Trophy Points:
    122
    @TnA it would be the thread priority, also getting the sample bitrate etc from the file is not going to happen anytime soon it will be a static setting of 22.050Hz for quite a while.

    During my tests I already had a cfg saved with bgm enabled and the device specified which is why it seemed fine so it must still be trying to run the thread even if it fails to find a file.

    Thanks for testing guys I'll have to try fix that issue and test without a cfg file and wave already set up. I'll try fix it quick to get a proper test out.

    Edit: also testing from mass in the way you've shown is fine, that's how I was testing
     
  2. 1,326
    719
    222
    TnA

    TnA Senior Member

    Joined:
    Jul 1, 2018
    Messages:
    1,326
    Likes Received:
    719
    Trophy Points:
    222
    Gender:
    Male
    Location:
    Germany --> Saxony
    Yes, but you could mess things up, if you play too much with thread-priority and a slight buffer-increase might have worked (around the issue) as well and still in an easy fashion. That's why I mentioned both... ;)

    Aaah... I had the placeholder for BGM on, but no device specified!! Error spottet? o_O

    Regarding the fixed sample-rate and etc. (as of now/yet)... No problem! Once in a while a 'samaritan' comes around. ;)

    Great work!
     
  3. 1,641
    1,298
    347
    jolek

    jolek Senior Member

    Joined:
    Dec 29, 2017
    Messages:
    1,641
    Likes Received:
    1,298
    Trophy Points:
    347
    Gender:
    Male
    Are there any plans for supporting other (FLAC, ape, ALAC, mp3, ogg) audio codecs for BGM?
     
  4. 1,326
    719
    222
    TnA

    TnA Senior Member

    Joined:
    Jul 1, 2018
    Messages:
    1,326
    Likes Received:
    719
    Trophy Points:
    222
    Gender:
    Male
    Location:
    Germany --> Saxony
    That would need a decoding-lib for these kind of Codecs (i.e. ffmpeg, I think) + linking the raw/decoded output to AUDSRV + probably also support for it to retrieve sample-rate, etc. properly...

    On another note... Technically, OPL could then even be reused as a Media-Player for Audio-Files, if the GUI would support it!


    Edit: But I think that there are some more important things to do yet. ;)
     
    Last edited: Oct 19, 2018
  5. 191
    271
    122
    Krah

    Krah Developer

    Joined:
    Jul 20, 2018
    Messages:
    191
    Likes Received:
    271
    Trophy Points:
    122
    This should fix this problem, I wasn't doing enough to stop creating and running the thread if it failed to load a wav file.

    I should have mention before also like @TnA pointed out your wav file needs to be
    • 16 bit, stereo, 22050Hz
    other wise it wont playback at the correct rate.

    as for the other suggestions, they will take longer to try sort out..i'll give it a go but no promises, I think decoding compressed audio formats is punching above my weight a bit ;)
     

    Attached Files:

    TnA and jolek like this.
  6. 191
    271
    122
    Krah

    Krah Developer

    Joined:
    Jul 20, 2018
    Messages:
    191
    Likes Received:
    271
    Trophy Points:
    122
    @sp193
    Do you have any ideas what would be causing this? I thought it would be thread starvation so I tried making the sound thread the highest priority (I wouldn't leave it this way) just to see if that was the cause of the problem, also tried adjusting the chunk size in bgmPlay but the problem still remains.
    Could the threads stack size affect this? I'm not really sure what the stack size should be.
     
    TnA likes this.
  7. 1,641
    1,298
    347
    jolek

    jolek Senior Member

    Joined:
    Dec 29, 2017
    Messages:
    1,641
    Likes Received:
    1,298
    Trophy Points:
    347
    Gender:
    Male
    Version OPLSNDTEST0.8.1 seems to boot fine.
    When I'll have more time, I'll also check BGM.

    - Thanks.
     
  8. 1,326
    719
    222
    TnA

    TnA Senior Member

    Joined:
    Jul 1, 2018
    Messages:
    1,326
    Likes Received:
    719
    Trophy Points:
    222
    Gender:
    Male
    Location:
    Germany --> Saxony
    Neither changing thread-priority, nor Buffer-/Chunk-Size did affect it?

    Then I suppose it is rather a 'multithreading-issue' (similar to the issue in the beginning), like 'transferring sound-chunk, while arts are read&shown'. :D

    ...but I am not saying, that the stack-size couldn't have an effect...
     
  9. 778
    1,395
    222
    sp193

    sp193 Developer

    Joined:
    Oct 13, 2014
    Messages:
    778
    Likes Received:
    1,395
    Trophy Points:
    222
    Location:
    Singapore
    Home Page:
    The stack size does not affect performance.

    Since the art assets are huge, it will naturally take time to read via USB 1.1. Those files are read in one go, tying up the USB device in the process.
     
  10. 1,326
    719
    222
    TnA

    TnA Senior Member

    Joined:
    Jul 1, 2018
    Messages:
    1,326
    Likes Received:
    719
    Trophy Points:
    222
    Gender:
    Male
    Location:
    Germany --> Saxony
    It also happens, if you have only one game installed and only the Art for that specific game (I tested it via SMB.) and the BGM on another device like USB (and it should work simultaneously!)!

    ...and if it/speed were the only problem, there would be some (noticeable?) difference by increasing the buffer (or not?)...

    Well, I haven't pointed out the stack, but rather that it might be an improper multithreading 'between' the BGM-thread/transfer/whatever and the art-related functions! ;)
     
    Last edited: Oct 20, 2018
  11. 1,326
    719
    222
    TnA

    TnA Senior Member

    Joined:
    Jul 1, 2018
    Messages:
    1,326
    Likes Received:
    719
    Trophy Points:
    222
    Gender:
    Male
    Location:
    Germany --> Saxony
    I just noticed, that the same happens, if you save a config or change a theme... ;)
     
  12. 191
    271
    122
    Krah

    Krah Developer

    Joined:
    Jul 20, 2018
    Messages:
    191
    Likes Received:
    271
    Trophy Points:
    122
    There is nothing wrong in relation to this..there is only one drawing thread......

    I see thank you, the same thing happens when bgm is played back from internal HDD..Seems like its just too much for the CPU to handle? Should I just forget bgm?
     
  13. 191
    271
    122
    Krah

    Krah Developer

    Joined:
    Jul 20, 2018
    Messages:
    191
    Likes Received:
    271
    Trophy Points:
    122
    @sp193
    For the meantime I have removed all BGM code and made the SFX code into a single commit here if you want to check it out:

    https://github.com/KrahJohlito/Open-PS2-Loader/commit/606a882e5e90e1b809fdba864cfc300e28549079

    I think sfx is ready to be merged but since you wrote a substantial amount of the code I would like to ask your permission before I make a pull request.

    Also I know you don't oversee OPL anymore but everyone in the scene respects your opinion so your approval would go a long way to getting this feature merged.

    Thank you.
     
    svotib, Tupakaveli and TnA like this.
  14. 6,478
    6,151
    622
    sandungas

    sandungas Moderator Developer

    Joined:
    Dec 31, 2014
    Messages:
    6,478
    Likes Received:
    6,151
    Trophy Points:
    622
    Location:
    Babylon 20xxE series
    So if the BGM is smaller it should work ?
    Im thinking there is a backup manager for PS3 named iris that has support for MOD audio, and one of the programmers that was working in it was hermes that i think it was working too in PS2, not sure im what though, but maybe the PS2 SDK supports MOD audio ?

    Is a bit limited because you cant convert audio wave formats to mod, but there are databases with lot of songs freelly available http://modarchive.org/index.php?request=view_genres
     
    Krah likes this.
  15. 1,326
    719
    222
    TnA

    TnA Senior Member

    Joined:
    Jul 1, 2018
    Messages:
    1,326
    Likes Received:
    719
    Trophy Points:
    222
    Gender:
    Male
    Location:
    Germany --> Saxony
    No, it should work with a 100MB-WAV as well, since it is streamed... However, that streaming gets kind of interrupted, when ART is loaded.

    If you scroll through the games and have all kinds of big Art-files transfered, the BGM will replay the last buffered sample, as long as there is no new data.

    Another thing which is missing, is a call to stop playback, once the USB-Device is unplugged.
     
    Krah and sandungas like this.
  16. 1,326
    719
    222
    TnA

    TnA Senior Member

    Joined:
    Jul 1, 2018
    Messages:
    1,326
    Likes Received:
    719
    Trophy Points:
    222
    Gender:
    Male
    Location:
    Germany --> Saxony
    I hope the SFX-Stuff and some other things (info-page-related things) on Krah's repo can be merged soon (and I hope @sp193 gives his o.k. as well [for the sound-related stuff]).

    BGM and other stuff can also be included later, once it works properly in any occasion...

    WhyTF do I have the feeling, that someone made some trials with improving it?!?
     
    Krah and sandungas like this.
  17. 778
    1,395
    222
    sp193

    sp193 Developer

    Joined:
    Oct 13, 2014
    Messages:
    778
    Likes Received:
    1,395
    Trophy Points:
    222
    Location:
    Singapore
    Home Page:
    That would be...impossible. The EE is equivalent to a 300MHz computer, designed for games that have BGM. On the other hand, it might not be so good for decoding multimedia with codecs that are not optimized for it.

    I think the problem is with how your are not actually streaming. You read really small chunks of sound samples, which need to be read within the amount of time required for one bank to be played by the SPU2, which is not much.
    To actually stream, you need to have a ring buffer, which contains multiple partitions. As sound is being played, the partitions are being filled. So that when sound data must be uploaded to the SPU2, there is virtually no waiting time. OPL does have streaming.c, although some work might be needed to adapt it to work from the EE, to be also free of libcdvd's definitions (it was meant to replace CDVDMAN/CDVDSTM's functionality).

    The logic is that a lot of interfaces on the PS2 do better for much longer reads. Otherwise, the overhead will be too much.

    I have not been closely following your progress due to being busy with priorities in life, but wow. Congratulations on completing the voice feature.

    As long as there is an option for enabling/disabling this feature that does work, I am okay with it.
     
    Krah, TnA and sandungas like this.
  18. 1,326
    719
    222
    TnA

    TnA Senior Member

    Joined:
    Jul 1, 2018
    Messages:
    1,326
    Likes Received:
    719
    Trophy Points:
    222
    Gender:
    Male
    Location:
    Germany --> Saxony
    Oh, great analysis @sp193! I feel I was 'not seeing the wood/forest, due to all these trees standing in the way/view' (an idiom, essentially meaning that I had the problem right in front of my eyes and was still too blind to see it... Embarrassing... Just as if someone forgets a freakin' semicolon or 'waved bracket'...

    You are totally correct, it is rather 'chunked reads (in blocks)', rather than continued streaming (including a ring-buffer)!

    Why do you have to be 'someone' in pretty much any case? Lol :D
    No pun intended! It is great to see it and without all your contributions, the PS2-scene would be far less advanced.


    Great, that you are also fine with a merge! :)

    @Krah: PR to ifcaro-repo? :)
     
  19. 191
    271
    122
    Krah

    Krah Developer

    Joined:
    Jul 20, 2018
    Messages:
    191
    Likes Received:
    271
    Trophy Points:
    122
    For about a year on and off I've been looking into the idea of sound in OPL, I was going to try MODs at one point using the ps2 amiga mod lib. but it looks like sp193 just pointed out the problem :encouragement:

    Thanks for clearing that up, I was reading about circular FIFO ring buffers about a week ago and it looked complicated. It's good to know that's likely the cause of the problem as even though it seems complex I wouldn't be wasting my time if I were to try learn about it :nervous:

    I'm kind of undecided now mate, @sandungas made some good suggestions in the other thead. I feel like I should at least try them locally to see if it improves the 'feel' of the gui sfx before proceeding.

    Thanks mate :congratulatory: yea it all works and is a run-time option, if I were to make changes before a pull request it would just be to the specific sounds themselves. code structure is all complete.
     
    sandungas, Tupakaveli and TnA like this.
  20. 1,326
    719
    222
    TnA

    TnA Senior Member

    Joined:
    Jul 1, 2018
    Messages:
    1,326
    Likes Received:
    719
    Trophy Points:
    222
    Gender:
    Male
    Location:
    Germany --> Saxony
    Well, other formats would be interesting, but certainly not needed and (IMO) of less importance than other things.

    Interesting things for now (just my opinion):
    • Streaming with a ring-buffer, etc.
    • The 'divide and conquer'-approach of the 'pathing' would need to be extended, if per-game-BGM/Sounds is ever going to be supported.
    On another note... If per-game-bgm/sounds ever get implemented, something like MP3-Support would be interesting or the storage for sounds for i.e. 30 games would be quite something already... A one minute BGM would be ~5MB at it's current 'rate' (sample-rate, bit-rate and channel-number) per game)... 150MB... Well, still o.k. but as an MP3, it would need ~15MB for all games... 150MB for 300 games...

    You can either 'just use it' (meaning you can partially just 'access' external functions) or learn why it has a 'partitioned' buffer, how the transfer is done and the buffer is handled/accessed, etc. Actually I am certain that you understand the concept quite fast. :)

    Regarding FIFO and LIFO: Well there's not soooo much to know about it (IMO)... FIFO is like sending water (data, etc.) through a tube (buffer) and LIFO like stacking (hence the word Stack) some pancakes (instructions, etc.). That's not all, but the most important info densed into a sentence.

    Interesting!

    Hm... Alright let's see what matches best.

    Aaaah, you never know! :'-D
     
    sandungas likes this.
Thread Status:
Not open for further replies.

Share This Page