newsAdvanced Gtk+ Sequencer - News: AgsSoundContainer and AgsSoundResource interfaces

 
 
Latest News
GSequencer v3.6.x release goals posted by jkraehemann, Fri 31 Jul 2020 10:17:04 AM UTC - 0 replies
GSequencer v3.4.x release goals posted by jkraehemann, Thu 11 Jun 2020 06:58:14 PM UTC - 0 replies
GSequencer v3.3.x replaced all recalls by ags-fx engine posted by jkraehemann, Wed 20 May 2020 07:25:15 AM UTC - 0 replies
Refactor GSequencer's recalls - the ags-fx engine posted by jkraehemann, Sun 03 May 2020 12:08:19 AM UTC - 0 replies
GSequencer v3.3.x release goals posted by jkraehemann, Fri 17 Apr 2020 12:36:11 PM UTC - 0 replies
[Submit News]
[97 news in archive]

AgsSoundContainer and AgsSoundResource interfaces

Item posted by Joël Krähemann <jkraehemann> on Mon 07 May 2018 03:48:09 PM UTC.

AgsSoundContainer and AgsSoundResource superseeds AgsPlayable. The changes were just applied to:

  • AgsSndfile - implementing AgsSoundResource
  • AgsIpatch - implementing AgsSoundContainer

The API was extended and refactored. Thought it is not yet final the basics are there, yet. One thing missing is implementing following methods:

GList* (*get_resource_all)(AgsSoundContainer *sound_container);
GList* (*get_resource_by_name)(AgsSoundContainer *sound_container,
                               gchar *resource_name);
GList* (*get_resource_by_index)(AgsSoundContainer *sound_container,
                                guint resource_index);
GList* (*get_resource_current)(AgsSoundContainer *sound_container);

AgsIpatchSample implementing AgsSoundResource

The new object AgsIpatchSample was introduced to implement missing functionality. AgsSoundContainer shall return objects implementing AgsSoundResource.

So it works like following to obtain all samples:

  GList *sound_resource;

  sound_resource = ags_sound_container_get_resource_all(AGS_SOUND_CONTAINER(ipatch));

AgsSndfile implementing AgsSoundResource

Since WAV, FLAC, AIFF or OGG files is a sound resource, the object implements AgsSoundResource. The object has been refactored, yet.

To make the API straight-forward - analogously to AgsSoundcard interface - the AgsSoundResource provides following functions:

gboolean ags_sndfile_info(AgsSoundResource *sound_resource,
                          guint *frame_count,
                          guint *loop_start, guint *loop_end);
void ags_sndfile_set_presets(AgsSoundResource *sound_resource,
                             guint channels,
                             guint samplerate,
                             guint buffer_size,
                             guint format);
void ags_sndfile_get_presets(AgsSoundResource *sound_resource,
                             guint *channels,
                             guint *samplerate,
                             guint *buffer_size,
                             guint *format);

Special about it is you read one single audio channel, others get cached in the buffer to reduce disk overhead:

/* read sample data */
guint ags_sound_resource_read(AgsSoundResource *sound_resource,
                              void *dbuffer,
                              guint audio_channel,
                              guint frame_count, guint format);

/* write sample data */
void ags_sound_resource_write(AgsSoundResource *sound_resource,
                              void *sbuffer,
                              guint audio_channel,
                              guint frame_count, guint format);

So the buffer size of AgsSoundResource should be the frame count you request of AgsSoundResource.


by Joël

No messages in AgsSoundContainer and AgsSoundResource interfaces

 

Back to the top


Powered by Savane 3.5