Browse Source

espeakedit: move the remaining prosodydisplay.cpp code into compiledata.cpp

master
Reece H. Dunn 9 years ago
parent
commit
1a19319979
3 changed files with 59 additions and 106 deletions
  1. 0
    1
      Makefile.am
  2. 59
    1
      src/compiledata.cpp
  3. 0
    104
      src/prosodydisplay.cpp

+ 0
- 1
Makefile.am View File

espeakedit_SOURCE = \ espeakedit_SOURCE = \
src/compiledata.cpp \ src/compiledata.cpp \
src/espeakedit.cpp \ src/espeakedit.cpp \
src/prosodydisplay.cpp \
src/spect.cpp src/spect.cpp


if OPT_KLATT if OPT_KLATT

+ 59
- 1
src/compiledata.cpp View File

#define wxOPEN wxFD_OPEN #define wxOPEN wxFD_OPEN
#endif #endif


typedef struct {
unsigned int value;
char *name;
} NAMETAB;

NAMETAB *manifest = NULL;
int n_manifest;

extern char path_source[sizeof(path_home)+20]; extern char path_source[sizeof(path_home)+20];


extern int progress_max; extern int progress_max;
extern "C" int utf8_in(int *c, const char *buf); extern "C" int utf8_in(int *c, const char *buf);
extern "C" int utf8_out(unsigned int c, char *buf); extern "C" int utf8_out(unsigned int c, char *buf);
extern void DrawEnvelopes(); extern void DrawEnvelopes();
extern void ReadPhondataManifest();


typedef struct { typedef struct {
const char *mnem; const char *mnem;
USHORT *prog_out_max; USHORT *prog_out_max;
USHORT prog_buf[MAX_PROG_BUF+20]; USHORT prog_buf[MAX_PROG_BUF+20];


static void ReadPhondataManifest()
{
// Read the phondata-manifest file
FILE *f;
int n_lines=0;
int ix;
char *p;
unsigned int value;
char buf[sizeof(path_home)+40];
char name[120];

sprintf(buf,"%s%c%s",path_home,PATHSEP,"phondata-manifest");
if((f = fopen(buf, "r")) == NULL)
return;

while(fgets(buf, sizeof(buf), f) != NULL)
n_lines++;

rewind(f);

if(manifest != NULL)
{
for(ix=0; ix < n_manifest; ix++)
free(manifest[ix].name);
}

if((manifest = (NAMETAB *)realloc(manifest, n_lines * sizeof(NAMETAB))) == NULL)
{
fclose(f);
return;
}

n_manifest = 0;
while(fgets(buf, sizeof(buf), f) != NULL)
{
if(!isalpha(buf[0]))
continue;

if(sscanf(&buf[2], "%x %s", &value, name) == 2)
{
if((p = (char *)malloc(strlen(name)+1)) != NULL)
{
strcpy(p, name);
manifest[n_manifest].value = value;
manifest[n_manifest].name = p;
n_manifest++;
}
}
}
fclose(f);
}


static const char *KeyToMnem(keywtab_t *ktab, int type, int value) static const char *KeyToMnem(keywtab_t *ktab, int type, int value)
{//=============================================================== {//===============================================================

+ 0
- 104
src/prosodydisplay.cpp View File

/***************************************************************************
* Copyright (C) 2005 to 2014 by Jonathan Duddington *
* email: [email protected] *
* Copyright (C) 2015 by Reece H. Dunn *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 3 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write see: *
* <http://www.gnu.org/licenses/>. *
***************************************************************************/

#include "speech.h"

#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef struct {
unsigned int value;
char *name;
} NAMETAB;

NAMETAB *manifest = NULL;
int n_manifest;

const char *LookupManifest(unsigned int addr)
{//=============================================
int ix;

if(manifest != NULL)
{
for(ix=0; ix < n_manifest; ix++)
{
if(manifest[ix].value == addr)
return(manifest[ix].name);
if(manifest[ix].value > addr)
break;
}
}
return("");
}


void ReadPhondataManifest()
{//=========================
// Read the phondata-manifest file
FILE *f;
int n_lines=0;
int ix;
char *p;
unsigned int value;
char buf[sizeof(path_home)+40];
char name[120];

sprintf(buf,"%s%c%s",path_home,PATHSEP,"phondata-manifest");
if((f = fopen(buf, "r")) == NULL)
return;

while(fgets(buf, sizeof(buf), f) != NULL)
n_lines++;

rewind(f);

if(manifest != NULL)
{
for(ix=0; ix < n_manifest; ix++)
free(manifest[ix].name);
}

if((manifest = (NAMETAB *)realloc(manifest, n_lines * sizeof(NAMETAB))) == NULL)
{
fclose(f);
return;
}

n_manifest = 0;
while(fgets(buf, sizeof(buf), f) != NULL)
{
if(!isalpha(buf[0]))
continue;

if(sscanf(&buf[2], "%x %s", &value, name) == 2)
{
if((p = (char *)malloc(strlen(name)+1)) != NULL)
{
strcpy(p, name);
manifest[n_manifest].value = value;
manifest[n_manifest].name = p;
n_manifest++;
}
}
}
fclose(f);
}

Loading…
Cancel
Save