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.


Topics - s.baus

Pages: [1]
1
Audio / Using SoundBuffer to split audio files?
« on: February 24, 2018, 01:17:29 pm »
Hello everybody,
I use SFML successfully inside my project for audio playback and like it very much. I use the C# binding and now have the task to split an audio file into little files (one large file about 2 hours into files of some minutes). Since I need a plattform independent framework (my project is build with mono/gtk-sharp,etc.) and didn't find any valuable framework I thought of using SFML for this task. So I took a look inside and found the SoundBuffer class, which already has the SaveToFile method and the internal handling for different file formats (the audio file can be ogg/wave/flac/mp3 (I know, it is not supported by SFML, wrote a wrapper myself)). The splitting will be done from time x to time y. How can I find out, where the samples of SoundBuffer belong to, meaning, which time they stand for?

Do you think this task can be achieved with this approach?
Thanks for respones.
Sven

2
C / CSFML for Linux 2.4
« on: December 31, 2017, 01:38:16 pm »
Hello everybody,
I would like to update the SFML Binding for .Net and read on the forum that I just need to update the CSFML binding. Since I use SFML on Windows and Linux I went to the download page, but couldn't find the download for Linux for Version 2.4. Are the Links missing?

Thanks for the response
Sven

3
DotNet / Waiting for SFML.Net 2.3
« on: May 22, 2015, 08:21:26 am »
Hello together,

since SFML 2.3 was released, when will there be a release 2.3 of SFML.Net? Thanks for your answers :).

Greetings
Sven

4
C / Problem building CSFML Master on linux
« on: April 14, 2015, 10:00:42 am »
Hello,
I'm currently trying to build the CSFML master branch on linux. But I get the following error:

[ 46%] Building CXX object src/SFML/Graphics/CMakeFiles/csfml-graphics.dir/RenderTexture.cpp.o                                                                  
In file included from /home/sven/Downloads/CSFML-master/src/SFML/Graphics/RenderTexture.cpp:32:0:
/home/sven/Downloads/CSFML-master/src/SFML/Graphics/ShapeStruct.h:54:26: Fehler: in Konflikt stehenden Rückgabetyp für »virtual unsigned int sfShapeImpl::getPointCount() const« angegeben
     virtual unsigned int getPointCount() const
                          ^
In file included from /home/sven/Downloads/CSFML-master/src/SFML/Graphics/ShapeStruct.h:32:0,
                 from /home/sven/Downloads/CSFML-master/src/SFML/Graphics/RenderTexture.cpp:32:
/usr/local/include/SFML/Graphics/Shape.hpp:196:25: Fehler:   »virtual std::size_t sf::Shape::getPointCount() const« wird überschrieben
     virtual std::size_t getPointCount() const = 0;
                         ^
In file included from /home/sven/Downloads/CSFML-master/src/SFML/Graphics/RenderTexture.cpp:32:0:
/home/sven/Downloads/CSFML-master/src/SFML/Graphics/ShapeStruct.h:87:25: Fehler: Feld »sfShape::This« kann nicht als vom abstrakten Typ »sfShapeImpl« deklariert werden
     sfShapeImpl         This;
                         ^
/home/sven/Downloads/CSFML-master/src/SFML/Graphics/ShapeStruct.h:41:7: Anmerkung:   denn die folgenden virtuellen Funktionen sind rein innerhalb »sfShapeImpl«:
 class sfShapeImpl : public sf::Shape
       ^
In file included from /home/sven/Downloads/CSFML-master/src/SFML/Graphics/ShapeStruct.h:32:0,
                 from /home/sven/Downloads/CSFML-master/src/SFML/Graphics/RenderTexture.cpp:32:
/usr/local/include/SFML/Graphics/Shape.hpp:213:22: Anmerkung:   virtual sf::Vector2f sf::Shape::getPoint(std::size_t) const
     virtual Vector2f getPoint(std::size_t index) const = 0;
                      ^
make[2]: *** [src/SFML/Graphics/CMakeFiles/csfml-graphics.dir/RenderTexture.cpp.o] Fehler 1
make[1]: *** [src/SFML/Graphics/CMakeFiles/csfml-graphics.dir/all] Fehler 2
make: *** [all] Fehler 2
[root@localhost CSFML-master

Anyone ideas, why it fails? Thanks for your help.

5
DotNet / Performanceproblems with 2.2?
« on: March 18, 2015, 03:11:10 pm »
Hello everybody,

I'm facing performanceproblems when setting the PlayingOffset with 2.2. Is there anything known? With an ogg file with a length of about 2 hours, setting the PlayingOffset to lets say about 1hour 30 minutes, I need to wait about 30 seconds for the code to run on. Is anybody facing this problem?

Thanks for your help
Sven

6
DotNet / Setting PlayingOffset before starting playback
« on: October 28, 2014, 07:34:57 pm »
Hello everybody,

I'm using SFML in my Cuesheet Application and have problem with audio playback. I want to start the playback at an offset, which is not the start of the file. Therefore I use this code:

if (this.music != null)
            {
                this.music.PlayingOffset = offset;
                this.music.Play();
                this.music.Volume = this.fVolume;
                this.tUpdateGUI.Start();
                playing = true;
            }

But the playback starts at the beginning, not the offset. Any idea why? Thanks for your help :).

Sven

7
DotNet / Problems with NLayer: System.IO.EndOfStreamException
« on: September 05, 2014, 11:56:41 am »
Hello,

I implemented a SoundStream which can read MP3 Codec via Nlayer (https://nlayer.codeplex.com/). It works fine, but sometimes I get a System.IO.EndOfStreamException from NLayer. It appers randomly and the developer is not shure, where it comes from, so I wanted to ask here, if you see any errors in my implementation:

namespace AudioCuesheetEditor.AudioBackend.SFML
{
    /// <summary>
    /// Class for mp3 decoded audio files to use in SFML as Soundstream, since SFML doesn't support mp3 decoding (for legal reasons).
    /// </summary>
    public class Mp3StreamSFML : SoundStream
    {
        private static readonly Logfile log = Logfile.getLogfile(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
        private MpegFile mp3file;
        private Mutex mutex;

        /// <summary>
        /// Initializes a new instance of the <see cref="AudioCuesheetEditor.AudioBackend.SFML.Mp3StreamSFML"/> class.
        /// </summary>
        /// <param name="_filename">Full path to the file</param>
        public Mp3StreamSFML(String _filename)
        {
            log.debug("Constructor called with " + _filename);
            this.mp3file = new MpegFile(_filename);
            this.Initialize((uint)this.mp3file.Channels, (uint)this.mp3file.SampleRate);
            this.mutex = new Mutex();
        }

        public TimeSpan Duration
        {
            get
            {
                log.debug("Duration = " + this.mp3file.Duration);
                return this.mp3file.Duration;
            }
        }

        #region implemented abstract members of SoundStream

        protected override bool OnGetData(out short[] samples)
        {
            log.debug("OnGetData called");
            this.mutex.WaitOne();
            //Buffer data for about 1 second
            float[] normalizedaudiodata = new float[48000];
            int readSamples = this.mp3file.ReadSamples(normalizedaudiodata, 0, normalizedaudiodata.Length);
            short[] pcmaudiodata;
            if (readSamples > 0)
            {
                pcmaudiodata = new short[readSamples]; // converted data
                for (int i = 0; i < readSamples; i++)
                {
                    // clip the data
                    if (normalizedaudiodata[i] > 1.0f)
                    {
                        normalizedaudiodata[i] = 1.0f;
                    }
                    else
                    {
                        if (normalizedaudiodata[i] < -1.0f)
                        {
                            normalizedaudiodata[i] = -1.0f;
                        }
                    }
                    // convert to pcm data
                    pcmaudiodata[i] = (short)(normalizedaudiodata[i] * short.MaxValue);
                }
                samples = pcmaudiodata;
                this.mutex.ReleaseMutex();
                return true;
            }
            else
            {
                samples = null;
                this.mutex.ReleaseMutex();
                return false;
            }
        }

        protected override void OnSeek(TimeSpan timeOffset)
        {
            log.debug("OnSeek called with " + timeOffset);
            this.mutex.WaitOne();
            if ((timeOffset <= this.mp3file.Duration) && (timeOffset >= TimeSpan.Zero))
            {
                while (this.mp3file.CanSeek == false)
                {
                    Thread.Sleep(100);
                }
                this.mp3file.Time = timeOffset;
            }
            this.mutex.ReleaseMutex();
        }

        #endregion
    }
}

Exception:

Quote
16.07.2014 15:47:37 AudioCuesheetEditor.AudioBackend.SFML.Mp3StreamSFML: ERROR | System.IO.EndOfStreamException: Es wurde versucht, über das Ende des Datenstroms hinaus zu lesen.
bei NLayer.Decoder.MpegFrame.ReadBits(Int32 bitCount) in d:\tmp\AudioCuesheetEditor\src\NLayer\Decoder\MpegFrame.cs:Zeile 528.
bei NLayer.Decoder.LayerIIIDecoder.ReadSideInfo(IMpegFrame frame) in d:\tmp\AudioCuesheetEditor\src\NLayer\Decoder\LayerIIIDecoder.cs:Zeile 687.
bei NLayer.Decoder.LayerIIIDecoder.DecodeFrame(IMpegFrame frame, Single[] ch0, Single[] ch1) in d:\tmp\AudioCuesheetEditor\src\NLayer\Decoder\LayerIIIDecoder.cs:Zeile 502.
bei NLayer.MpegFrameDecoder.DecodeFrameImpl(IMpegFrame frame, Array dest, Int32 destOffset) in d:\tmp\AudioCuesheetEditor\src\NLayer\MpegFrameDecoder.cs:Zeile 110.
bei NLayer.MpegFrameDecoder.DecodeFrame(IMpegFrame frame, Single[] dest, Int32 destOffset) in d:\tmp\AudioCuesheetEditor\src\NLayer\MpegFrameDecoder.cs:Zeile 74.
bei NLayer.MpegFile.set_Position(Int64 value) in d:\tmp\AudioCuesheetEditor\src\NLayer\MpegFile.cs:Zeile 92.
bei NLayer.MpegFile.set_Time(TimeSpan value) in d:\tmp\AudioCuesheetEditor\src\NLayer\MpegFile.cs:Zeile 107.
bei AudioCuesheetEditor.AudioBackend.SFML.Mp3StreamSFML.OnSeek(TimeSpan timeOffset) in d:\tmp\AudioCuesheetEditor\src\AudioCuesheetEditor\AudioBackend\SFML\Mp3StreamSFML.cs:Zeile 92.

My code can be found here (for further searching): http://sourceforge.net/p/audiocuesheet/code/HEAD/tree/trunk/

I'm looking forward to hearing from you ;).

Greets
Sven

8
DotNet / Update GUI from AudioManager
« on: July 16, 2014, 11:42:08 am »
Hello everybody,

I want to use SFML in my little application, and have done some bindings. The application is written in C#, uses Mono on Linux and .NET on Windows. Now I want to update the GUI (Mainwindow) so it can display the current position. Therefore I wanted to add a thread in my audiomanager, that periodically triggers the GUI to grab new values (1 time a second), but that fails, since the thread of SFML seems to get out of control. Have you ever done something like this? How do others implement audio players? Any examples are welcome.
I hope you understand what I want to achieve, otherwise ask ;).
Greetings
Sven

9
DotNet / EntryPointNotFoundException on Mono (Linux)
« on: July 09, 2014, 09:14:26 am »
Hello,

I'm facing a EntryPointNotFoundException, when trying to run SFML.Net on Mono (Fedora Linux). I have installed the SFML package, have packed the SFML.Net libraries with my application and did a dllconfig:

sfmlnet-audio-2.dll.config:
Quote
<configuration>
   <dllmap dll="csfml-audio-2" target="libsfml-audio.so.2" os="linux"/>
   <dllmap dll="csfml-window-2" target="libsfml-window.so.2" os="linux"/>
   <dllmap dll="csfml-graphics-2" target="libsfml-graphics.so.2" os="linux" />
</configuration>

If I enter the code, where sound should be played, I get this Exception:
Quote
[sven@localhost AudioCuesheetEditor-linux-v1.1.3]$ mono AudioCuesheetEditor.exe
Marshaling clicked signal
Exception in Gtk# callback delegate
  Note: Applications can use GLib.ExceptionManager.UnhandledException to handle the exception.
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.EntryPointNotFoundException: sfMusic_createFromFile
  at (wrapper managed-to-native) SFML.Audio.Music:sfMusic_createFromFile (string)
  at SFML.Audio.Music..ctor (System.String filename) [0x00000] in <filename unknown>:0
  at AudioCuesheetEditor.AudioBackend.SFML.CustomMusicSFML..ctor (System.String filePath) [0x00000] in <filename unknown>:0
  at AudioCuesheetEditor.AudioBackend.AudioManagerSFML.setMusic () [0x00000] in <filename unknown>:0
  at AudioCuesheetEditor.AudioBackend.AudioManagerSFML.checkAndPlayMusic (TimeSpan offset) [0x00000] in <filename unknown>:0
  at AudioCuesheetEditor.AudioBackend.AudioManagerSFML.play () [0x00000] in <filename unknown>:0
  at MainWindow.btnPlayPauseClicked (System.Object sender, System.EventArgs e) [0x00000] in <filename unknown>:0
  at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&)
  at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0
  --- End of inner exception stack trace ---
  at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0
  at System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) [0x00000] in <filename unknown>:0
  at System.Delegate.DynamicInvokeImpl (System.Object[] args) [0x00000] in <filename unknown>:0
  at System.MulticastDelegate.DynamicInvokeImpl (System.Object[] args) [0x00000] in <filename unknown>:0
  at System.Delegate.DynamicInvoke (System.Object[] args) [0x00000] in <filename unknown>:0
  at GLib.Signal.ClosureInvokedCB (System.Object o, GLib.ClosureInvokedArgs args) [0x00000] in <filename unknown>:0
  at GLib.SignalClosure.Invoke (GLib.ClosureInvokedArgs args) [0x00000] in <filename unknown>:0
  at GLib.SignalClosure.MarshalCallback (IntPtr raw_closure, IntPtr return_val, UInt32 n_param_vals, IntPtr param_values, IntPtr invocation_hint, IntPtr marshal_data) [0x00000] in <filename unknown>:0
   at GLib.ExceptionManager.RaiseUnhandledException(System.Exception e, Boolean is_terminal)
   at GLib.SignalClosure.MarshalCallback(IntPtr raw_closure, IntPtr return_val, UInt32 n_param_vals, IntPtr param_values, IntPtr invocation_hint, IntPtr marshal_data)
   at Gtk.Application.gtk_main()
   at Gtk.Application.Run()
   at AudioCuesheetEditor.MainClass.Main(System.String[] args)
Has anybody had this? Am I doing something wrong in the dll config? Thanks for any help.

10
DotNet / NLayer MpegFile to SFML.Net SoundStream
« on: June 07, 2014, 12:28:53 pm »
Hello everybody,

I'm currently working on SFML.Net to expand with mp3 support. Therefore I wrote a Stream class which uses NLayer MpegFile to decode the mp3.

   
public class Mp3StreamSFML : SoundStream
    {
        private MpegFile mp3file;
        private int currentBufferSize;
        private short[] currentBuffer;

        public Mp3StreamSFML(String _filename)
        {
            mp3file = new MpegFile(_filename);
            Initialize((uint)mp3file.Channels, (uint)mp3file.SampleRate);
            currentBufferSize = 0;
            currentBuffer = new short[currentBufferSize];
        }

        #region implemented abstract members of SoundStream

        protected override bool OnGetData(out short[] samples)
        {
            if (currentBufferSize <= mp3file.Position)
            {
                byte[] buffer = new byte[512];
                if (mp3file.ReadSamples(buffer, 0, buffer.Length) > 0)
                {
                    Array.Resize(ref currentBuffer, currentBuffer.Length + (buffer.Length / 2));
                    Buffer.BlockCopy(buffer, 0, currentBuffer, currentBufferSize, buffer.Length);
                    currentBufferSize = currentBuffer.Length;
                }
                samples = currentBuffer;
                return true;
            }
            else
            {
                samples = currentBuffer;
                return false;
            }
        }

        protected override void OnSeek(TimeSpan timeOffset)
        {
            mp3file.Position = (long)timeOffset.TotalSeconds;
        }

        #endregion
    }

I use it this way:

                   
try
                    {
                        stream = new Mp3StreamSFML(this.objProgram.getObjCuesheet().getAudiofilePath(true));
                        stream.Play();
                        log.debug("samplerate = " + stream.SampleRate);
                    }
                    catch(Exception ex)
                    {
                        log.fatal(ex.ToString());
                    }

Unfortunately, there is not the correct sound played, its just "juttering" and sound really weird. What I'm doing wrong? Seems like a problem between the 2 Frameworks.

NLayer:https://nlayer.codeplex.com/

Thanks for your help ;).
Sven

Pages: [1]