Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - malkierian

Pages: 1 [2] 3
16
D / Re: String, Dstring, and Char[] oh my...
« on: December 23, 2013, 06:27:52 am »
And another development arrives.

So I tried adding a try...catch around my call to SoundBuffer.loadFromFile(), and while it is obviously erroring (I put an error message in there) since I caught the error, it actually goes on to load and play the sound fine.  I have no freaking idea what's going on at this point.

Here's the most basic code you could want to test it:
module main;

import dsfml.audio;
import dsfml.graphics;
import dsfml.window;

import std.stdio;

void main(string[] args)
{
//      new Soundboard().run();
        auto window = new RenderWindow(VideoMode(1280, 720), "Virtual Soundboard", Window.Style.Titlebar | Window.Style.Close);
        auto buffer = new SoundBuffer();
        auto sound = new Sound();
        writeln("Buffer and Sound instantiated");
        try
        {
                if(!buffer.loadFromFile("F:\\Soundboard\\Ogg\\AirLeak.ogg"))
                        return;
                writeln("Buffer loaded");
        }
        catch
        {
                writeln("Error loading file to buffer");
        }
        sound.setBuffer(buffer);
        sound.play();
        while (window.isOpen())
        {
                Event event;
                while(window.pollEvent(event))
                {
                        if(event.type == Event.EventType.Closed)
                        {
                                window.close();
                        }
                }
               
                window.clear(Color.Black);
               
                window.display();
        }
}
Just put in whatever sound file you want for the buffer and try commenting the try...catch.  It'll freeze.  But with it in there, it tells you in the console that there was an error loading the buffer (which I believe, if you run it without the try catch, it will tell you is an access violation in that line), but then successfully plays it before starting the main loop.

EDIT: This hack only seems to work for OGG files.  Try to do that with a WAV and it will still freeze the program.  And when the OGG file continues, it actually gives a core.exception.InvalidMemoryOperationError instead of an access violation.  This is extremely weird...

EDIT 2:  Even with that hack, it doesn't work every time, and I can't track down why not.

EDIT 3:  ACK!  It appears that every fifth time I run the program it works, and every now and then it will even load WAVs on that successful run.  WHAT THE HECK IS GOING ON?!  LOL.  This is so perplexing.

17
D / Re: DSFML-C "Nightlies"
« on: December 23, 2013, 01:16:51 am »
Also, for those who were used to building things in the past, is this download that is now linked to everywhere everything we need to get DSFML working on our system?  I.E. this has DSFML and DSFML-C all wrapped up and we don't need to build DSFML on these seemingly DSFML-C files?

18
D / Re: String, Dstring, and Char[] oh my...
« on: December 23, 2013, 01:07:55 am »
By way of bumping, I just wanted to report that Ogg files don't work with that code I posted either.  Same freezing.  Also, the message I get in console is

Stream closed?
Stream closed?

Yes, I get it twice for one file operation.

19
D / Re: String, Dstring, and Char[] oh my...
« on: December 21, 2013, 03:41:35 am »
Update:  If I feed the loadFromFile function a lstring literal, it still freezes the program.  This is a valid WAV file I'm trying to load, not even an Ogg.

20
D / Re: String, Dstring, and Char[] oh my...
« on: December 21, 2013, 01:57:21 am »
Oh my gosh, I think I figured it out.  So the file open dialog stuff is as follows:

auto openSoundFile()
{
        char[256] filenameBuffer;
        filenameBuffer[0] = 0;
        OPENFILENAME info;
        info.lStructSize = OPENFILENAME.sizeof;
        info.lpstrFilter = "Audio Files\0*.wav;*.ogg\0\0".ptr;
        info.lpstrFile = filenameBuffer.ptr;
        info.nMaxFile = filenameBuffer.length;
        if(GetOpenFileNameA(&info))
        {
                return to!string(filenameBuffer);
        }
        else return to!string("!!failed");
}

Apparently returning that as a string returns the entire char array, including the garbage after the file path, which my slice (temp.length - 1) then pulled for some reason.  Here's the code I'm using so you can at least try to debug if it's an issue in DSFML:

http://pastebin.com/Xfr53gNu

By the way, although the Text.setString works now, the program always stops responding when I uncomment the part for loading the SoundBuffer and I'm not sure why.

21
D / Re: String, Dstring, and Char[] oh my...
« on: December 20, 2013, 06:33:00 am »
Yeah, I think I edited my post after you replied.  I've tried that and it doesn't work.  It doesn't seem to work with anything but a literal.

EDIT:  After some creative Google searching, it seems that this is more a Dlang issue than it is an SFML issue.  Could there be something wrong in your binding that's causing it?

22
D / Re: String, Dstring, and Char[] oh my...
« on: December 20, 2013, 05:42:49 am »
Is there any reason you need your substring to be a dstring? Why not also make it a string as well and just use a slice?
I guess I may not have been clear enough in my original post, but SoundBuffer.loadFromFile() uses string, while Label.setString uses dstring, and neither will accept the other format.

EDIT: The biggest issue is that the Label.setString is the one I need to slice into, and that's what needs the dstring.  And when I try to do it (ala
Code: [Select]
label.setString(to!dstring(temp[(temp.lastIndexOf('\\') + 1)..(temp.length)].dup)); I get this error:
Code: [Select]
std.utf.UTFException@E:\Dlang\dmd2\windows\bin\..\..\src\phobos\std\utf.d(1113): Invalid UTF-8 sequence (at index 1), and I've already tested that setString works with a literal, and that slice actually works, believe it or not.  But when converting that slice to a dstring, if fails with that error I already mentioned.

23
D / String, Dstring, and Char[] oh my...
« on: December 20, 2013, 03:50:23 am »
OK, so I'm trying to use SFML's Audio module to play a sound, and I'm using the Windows headers to open the file (default Windows file dialog).  SoundBuffer.loadFromFile takes a "string" argument.  The Windows file dialog process takes a char[] array, and I am trying to use the return I get from the file select window to also form the default "tag", or in-program identifier, as a label as part of a sound actor class (custom class that handles play, stop and open buttons for a group, as well as the label), which also means I need to use a substring of the file name returned from the file select.  So essentially I need to go from char[] to string, and char[] to sub-dstring.  But I keep getting this error after picking the file and trying to load it:

std.utf.UTFException@E:\Dlang\dmd2\windows\bin\..\..\src\phobos\std\utf.d(1113): Invalid UTF-8 sequence (at index 1)

I am running the file selector in a separate function.  I have tried passing a pointer argument to the function to return through, and I've tried returning it directly, both fail.  How do I properly return a string/dstring argument from a function, and how do I properly/effectively convert between those three formats?

24
Audio / Re: Multiple Simultaneous Audio Output
« on: December 06, 2013, 05:31:36 pm »
Well, the virtual cable is already taken care of with the program Virtual Audio Cable, I would just need to tie into that.  Looks like I'll have to go into OpenAL and figure it out myself.  Thanks, though.

25
D / Font Issues
« on: December 06, 2013, 07:58:11 am »
So I'm trying to get a Text going in a class of mine, and in order to do that, I need a Font.  However, when I try this, and use font.loadfromFile(), I get 6 errors related to it:
Code: [Select]
unexpected ( in declarator
basic type expected, not "fonts/OratorStd.ttf"
found '"fonts/OratorStd.ttf"' when expecting ')'
no identifier for declarator font.loadFromFile(int)
semicolon expected following function declaration
declaration expected, not ')'
And when I hover over the line, I see "Parser Error: <Identifier> expected, <Literal> found!".  The issue I can see is that, for some reason, Font isn't showing as having any of the methods necessary to utilizing the class.  Whenever I type a period after my font object, NOTHING shows up.

Here's my code:
module sound;

import dsfml.graphics;
import scene2d.actor;

class Sound: Actor
{
        Sprite playSprite;
        Sprite stopSprite;
        Sprite folderSprite;

        auto font = new Font();
        font.loadFromFile("fonts/OratorStd.ttf");
        Text label = new Text("Uninitialized", font);
        this(Texture *play, Texture *stop, Texture *folder, int index)
        {
                int x, y;
                x = (index % 10) * 96 + (index % 10) * 16;
                y = (index % 9) * 16 + (index % 10) * 64;

                playSprite = new Sprite(play);
                playSprite.position(Vector2f(x, y + 32));
                stopSprite = new Sprite(play);
                stopSprite.position(Vector2f(x + 32, y + 32));
                folderSprite = new Sprite(play);
                folderSprite.position(Vector2f(x + 64, y + 32));
        }

        ~this()
        {
                ~playSprite();
                ~stopSprite();
                ~folderSprite();
        }

        override draw(Drawable surface)
        {
                surface.draw(label);
                surface.draw(playSprite);
                surface.draw(stopSprite);
                surface.draw(folderSprite);
        }
}

EDIT: Well, that was weird.  I moved the font loading into my main class and passed it as a parameter to the SoundActor constructor (the new name for the class), and everything seems to be working fine, though I still don't get the lookup window when calling a member...

26
Audio / Multiple Simultaneous Audio Output
« on: December 06, 2013, 02:39:33 am »
Is it possible, in 2.0, to output a single audio stream to two devices simultaneously?  I'm trying to make a virtual soundboard, but I need to be able to hook into at least two devices (a virtual cable that also has my microphone writing to it, and then to my headset speakers) to make it even worthwhile.  Even if it's not possible in SFML, is it possible, period?

27
D / Window Style Values
« on: December 05, 2013, 05:19:26 am »
Where are they located?  Using Style.DefaultStyle, like in renderwindow.d, tells me Style is an unknown identifier.

28
D / Re: dsfml\system.d cannot be read?
« on: December 04, 2013, 06:51:38 am »
Alright, so it looks like the issue is it's looking for the module in dsfml/system.d, but there isn't a file there.  Even though I'm clicking on the dsfml/system/package.d when typing the import statement and the completion window pops up, it's still looking for that system.d file.  However, I see in the OGL3 example on the wiki that I should be able to use that format (import dsfml.system;) and have it work.  So what am I doing wrong?

29
D / dsfml\system.d cannot be read?
« on: December 04, 2013, 05:43:31 am »
So I get Xamarin up and running with Mono-d, wonderful code lookup and such, get a very basic window coded out (took me a while to realize I didn't need to use the :: anymore and instead needed to use package names directly, and . for struct members), but when I go to compile, I get "Error: module system is in file 'dsfml\system.d' which cannot be read".  I have tried both having the imports set to the folder where the lib files are for DSFML, and having it set to the source files in the git repo I downloaded (not at the same time).  The lib files are listed in the linker.  Looking at the tooltips, it looks like I'm supposed to have it pointed to the lib folder.  But I don't understand why it's giving me this error.  Any ideas?

30
D / Re: Problems Compiling DSFML-C
« on: November 20, 2013, 04:51:20 am »
Also, I remember that it's built on 2.0, right?  Will any dev environment work with these libs?

By the way, is there an IRC channel you hang out in?  Is there an #sfml channel somewhere?

Pages: 1 [2] 3
anything