<commit_before>#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>

#include <directfb.h>

#include <lite/lite.h>
#include <lite/window.h>

#include <fusionsound.h>


static IFusionSound              *sound    = NULL;
static IFusionSoundMusicProvider *provider = NULL;
static IFusionSoundBuffer        *buffer   = NULL;
static IFusionSoundStream        *stream   = NULL;

static LiteWindow                *window;


static void
draw_scope( __s16 *data, int len )
{
     IDirectFBSurface *surface;
     DFBRectangle     *r;
     int               w, h;
     int               i, j, s;

     surface = window->box.surface;
     surface->AddRef( surface );
     surface->GetSize( surface, &w, &h );

     r = alloca( w * sizeof(DFBRectangle) ); 
     s = (len << 16) / w;
     for (i = 0, j = 0; i < w; i++, j += s) {
          int d;

          /* scale horizontally and convert to unsigned 16 mono */
          d = ((data[(j>>16)*2] + data[(j>>16)*2+1]) >> 1) + 32768;
          /* scale vertically and convert to signed */
          d = ((d * h) >> 16) - (h>>1);
               
          r[i].x = i;
          r[i].w = 1;
          if (d >= 0) {
               r[i].y = (h>>1) - d;
               r[i].h = d ? : 1;
          } else {
               r[i].y = h>>1;
               r[i].h = -d;
          }
     }

     surface->Clear( surface, window->bg.color.r, 
                              window->bg.color.g,
                              window->bg.color.b,
                              window->bg.color.a );
     surface->SetColor( surface, 0xff^window->bg.color.r,
                                 0xaf^window->bg.color.g,
                                 0x2f^window->bg.color.b,
                                 0xff );
     surface->FillRectangles( surface, r, w );
     surface->Flip( surface, NULL, 0 );
     surface->Release( surface );
}

static void
buffer_callback( int len, void *ctx )
{
     void *data;
     
     if (buffer->Lock( buffer, &data ) != DFB_OK)
          return;
<commit_msg>Generate a wave.<commit_after>#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>

#include <directfb.h>

#include <lite/lite.h>
#include <lite/window.h>

#include <fusionsound.h>


static IFusionSound              *sound    = NULL;
static IFusionSoundMusicProvider *provider = NULL;
static IFusionSoundBuffer        *buffer   = NULL;
static IFusionSoundStream        *stream   = NULL;

static LiteWindow                *window;


static void
draw_scope( __s16 *data, int len )
{
     IDirectFBSurface *surface;
     DFBRegion        *r;
     int               w, h;
     int               i, j, s;

     surface = window->box.surface;
     surface->AddRef( surface );
     surface->GetSize( surface, &w, &h );

     r = alloca( w * sizeof(DFBRegion) ); 
     s = (len << 16) / w;
    
     r[0].x1 =
     r[0].x2 = 0;
     r[0].y1 = 
     r[0].y2 = h/2 + ((data[0]*h) >> 16);   
     for (i = 1, j = s; i < w; i++, j += s) {
          r[i].x1 = 
          r[i].x2 = i;
          r[i].y1 = r[i-1].y2; 
          r[i].y2 = h/2 + ((data[(j>>16)*2]*h) >> 16);
     }

     surface->Clear( surface, window->bg.color.r, 
                              window->bg.color.g,
                              window->bg.color.b,
                              window->bg.color.a );
     surface->SetColor( surface, 0xff^window->bg.color.r,
                                 0xaf^window->bg.color.g,
                                 0x2f^window->bg.color.b,
                                 0xff );
     surface->DrawLines( surface, r, w );
     surface->Flip( surface, NULL, 0 );
     surface->Release( surface );
}

static void
buffer_callback( int len, void *ctx )
{
     void *data;
     
     if (buffer->Lock( buffer, &data ) != DFB_OK)
          return;

{'fraction_non_alphanumeric': 0.1483328957731688, 'fraction_numerical': 0.01864006300866369, 'mean_word_length': 1.4788549121665582, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 72, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '867114', 'n_tokens_mistral': 1333, 'n_tokens_neox': 1254, 'n_words': 295}