From d22983565893180d543aa4b3b8a96847cbd50397 Mon Sep 17 00:00:00 2001 From: Rob van Son Date: Mon, 7 Jun 2010 15:56:11 +0200 Subject: [PATCH] New Credits mechanism and tables --- Config.praat | 73 +--------------------------------------- Data/Credits_DE.Table | 40 ++++++++++++++++++++++ Data/Credits_EN.Table | 40 ++++++++++++++++++++++ Data/Credits_NL.Table | 40 ++++++++++++++++++++++ sgc2.praat | 92 +++++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 213 insertions(+), 72 deletions(-) create mode 100644 Data/Credits_DE.Table create mode 100644 Data/Credits_EN.Table create mode 100644 Data/Credits_NL.Table diff --git a/Config.praat b/Config.praat index c8e075d..703debc 100644 --- a/Config.praat +++ b/Config.praat @@ -328,7 +328,7 @@ procedure processConfigCredits .clickX .clickY .pressed$ .table$ = "Config" .label$ = "Credits" call Draw_button '.table$' '.label$' 1 - call write_credits + call write_text_table Credits_EN demoWaitForInput() call Draw_button '.table$' '.label$' 0 demo Erase all @@ -702,74 +702,3 @@ procedure sgc2wordlist .sourceDir$ endif endproc -# The Credits -procedure write_credits - .xleft = 20 - .xright = 90 - .ylow = 20 - .yhigh = 85 - .lineHeight = 2.5 - .referenceText$ = "organisational, and financial support from the staff and board of the Digitale Universiteit." - .creditsFontSize = 12 - - # Adapt size of button to length of text - .maxWidth = (.xright - .xleft) - 3 - call adjustFontSizeOnWidth '.creditsFontSize' '.maxWidth' '.referenceText$' - .creditsFontSize = adjustFontSizeOnWidth.newFontSize - if adjustFontSizeOnWidth.diff > 0 - .xright += adjustFontSizeOnWidth.diff/4 - .xleft -= 3*adjustFontSizeOnWidth.diff/4 - endif - call set_font_size '.creditsFontSize' - - demo Line width... 8 - demo Colour... {0.5,0.5,1} - demo Paint rectangle... {0.9,0.9,1} '.xleft' '.xright' '.ylow' '.yhigh' - demo Draw rectangle... '.xleft' '.xright' '.ylow' '.yhigh' - demo Line width... 'defaultLineWidth' - demo Black - .xleft += 2 - .dy = .lineHeight - .ytext = .yhigh - 2 - .dy - demo Text... '.xleft' Left '.ytext' Bottom SpeakGoodChinese version 2.0 - .ytext -= 2*.dy - demo Text... '.xleft' Left '.ytext' Bottom For more information, visit our website: http://www.speakgoodchinese.org - .ytext -= .dy - demo Text... '.xleft' Left '.ytext' Bottom Based on Praat (http://www.praat.org) - .ytext -= 2*.dy - demo Text... '.xleft' Left '.ytext' Bottom SpeakGoodChinese was supported by grant 6046 from the Digitale Universiteit - .ytext -= 2* .dy - demo Text... '.xleft' Left '.ytext' Bottom The SpeakGoodChinese Team - .ytext -= .dy - demo Text... '.xleft' Left '.ytext' Bottom * Guanqin Chen (HRO) - Founder and project manager, Language and Teaching - .ytext -= .dy - demo Text... '.xleft' Left '.ytext' Bottom * Zongyan Chen (HvA) - Language and Teaching - .ytext -= .dy - demo Text... '.xleft' Left '.ytext' Bottom * Eveline van Hagen (Fontys) - Language and Teaching - .ytext -= .dy - demo Text... '.xleft' Left '.ytext' Bottom * Stefan de Konink (UvA) - Lead programmer, User Interface - .ytext -= .dy - demo Text... '.xleft' Left '.ytext' Bottom * Lifeng Liu (HRO) - Language assistant - .ytext -= .dy - demo Text... '.xleft' Left '.ytext' Bottom * Rob van Son (UvA) - Coordinator technical work, Speech technology, demo GUI - .ytext -= .dy - demo Text... '.xleft' Left '.ytext' Bottom * Dennis Vierkant (UT) - User Interface and Language - .ytext -= .dy - demo Text... '.xleft' Left '.ytext' Bottom * David Weenink (UvA) - Praat programming, Algorithms We would like to thank - .ytext -= 2*.dy - demo Text... '.xleft' Left '.ytext' Bottom We would like to thank Paul Boersma (UvA) for his help with Praat linking - .ytext -= .dy - demo Text... '.xleft' Left '.ytext' Bottom and Tristian van Berkom for additional help with the localization code. - .ytext -= .dy - demo Text... '.xleft' Left '.ytext' Bottom J.E. Raaijmakers, R. van Rijsselt and S. Verhagen for feedback on the GUI and - .ytext -= .dy - demo Text... '.xleft' Left '.ytext' Bottom Praat library integration on Windows. - .ytext -= 2*.dy - demo Text... '.xleft' Left '.ytext' Bottom We are very grateful for all the practical, organisational, and financial - .ytext -= .dy - demo Text... '.xleft' Left '.ytext' Bottom support from the staff and board of the Digitale Universiteit. - - demoShow() - call set_font_size 'defaultFontSize' -endproc - diff --git a/Data/Credits_DE.Table b/Data/Credits_DE.Table new file mode 100644 index 0000000..ea9b272 --- /dev/null +++ b/Data/Credits_DE.Table @@ -0,0 +1,40 @@ +font size text +Helvetica 12 +Helvetica 16 SpeakGoodChinese version 2.0 +Helvetica 12 +Helvetica 12 For more information, visit our website: http://www.speakgoodchinese.org +Helvetica 12 Based on Praat (http://www.praat.org) +Helvetica 12 +Helvetica 12 SpeakGoodChinese was supported by grant 6046 from the Digitale Universiteit +Helvetica 12 The SpeakGoodChinese Team +Helvetica 12 * ##Guanqin Chen# (HRO) - Founder and project manager, Language and Teaching +Helvetica 12 * ##Zongyan Chen# (HvA) - Language and Teaching +Helvetica 12 * ##Eveline van Hagen# (Fontys) - Language and Teaching +Helvetica 12 * ##Stefan de Konink# (UvA) - Lead programmer, User Interface +Helvetica 12 * ##Lifeng Liu# (HRO) - Language assistant +Helvetica 12 * ##Rob van Son# (UvA) - Coordinator technical work, Speech technology, GUI +Helvetica 12 * ##Dennis Vierkant# (UT) - User Interface and Language +Helvetica 12 * ##David Weenink# (UvA) - Praat programming, Algorithms We would like to thank +Helvetica 12 +Helvetica 12 We would like to thank Paul Boersma (UvA) for his help with Praat linking and Tristian van Berkom +Helvetica 12 for additional help with the localization code. J.E. Raaijmakers, R. van Rijsselt and S. Verhagen +Helvetica 12 for feedback on the GUI and Praat library integration on Windows. +Helvetica 12 We are very grateful for all the practical, organisational, and financial support from the staff +Helvetica 12 and board of the Digitale Universiteit. +Helvetica 12 +Helvetica 12 Created and Copyrights 2007-2010 by Rob van Son (ACLC/UvA) - R.J.J.H.vanSon@gmail.com +Helvetica 12 +Courier 12 This program is free software: you can redistribute it and/or modify +Courier 12 it under the terms of the GNU General Public License as published by +Courier 12 the Free Software Foundation, either version 3 of the License, or +Courier 12 (at your option) any later version. +Courier 12 +Courier 12 This program is distributed in the hope that it will be useful, +Courier 12 but WITHOUT ANY WARRANTY; without even the implied warranty of +Courier 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +Courier 12 GNU General Public License for more details. +Courier 12 +Courier 12 You should have received a copy of the GNU General Public License +Courier 12 along with this program. If not, see . +Courier 12 + diff --git a/Data/Credits_EN.Table b/Data/Credits_EN.Table new file mode 100644 index 0000000..ea9b272 --- /dev/null +++ b/Data/Credits_EN.Table @@ -0,0 +1,40 @@ +font size text +Helvetica 12 +Helvetica 16 SpeakGoodChinese version 2.0 +Helvetica 12 +Helvetica 12 For more information, visit our website: http://www.speakgoodchinese.org +Helvetica 12 Based on Praat (http://www.praat.org) +Helvetica 12 +Helvetica 12 SpeakGoodChinese was supported by grant 6046 from the Digitale Universiteit +Helvetica 12 The SpeakGoodChinese Team +Helvetica 12 * ##Guanqin Chen# (HRO) - Founder and project manager, Language and Teaching +Helvetica 12 * ##Zongyan Chen# (HvA) - Language and Teaching +Helvetica 12 * ##Eveline van Hagen# (Fontys) - Language and Teaching +Helvetica 12 * ##Stefan de Konink# (UvA) - Lead programmer, User Interface +Helvetica 12 * ##Lifeng Liu# (HRO) - Language assistant +Helvetica 12 * ##Rob van Son# (UvA) - Coordinator technical work, Speech technology, GUI +Helvetica 12 * ##Dennis Vierkant# (UT) - User Interface and Language +Helvetica 12 * ##David Weenink# (UvA) - Praat programming, Algorithms We would like to thank +Helvetica 12 +Helvetica 12 We would like to thank Paul Boersma (UvA) for his help with Praat linking and Tristian van Berkom +Helvetica 12 for additional help with the localization code. J.E. Raaijmakers, R. van Rijsselt and S. Verhagen +Helvetica 12 for feedback on the GUI and Praat library integration on Windows. +Helvetica 12 We are very grateful for all the practical, organisational, and financial support from the staff +Helvetica 12 and board of the Digitale Universiteit. +Helvetica 12 +Helvetica 12 Created and Copyrights 2007-2010 by Rob van Son (ACLC/UvA) - R.J.J.H.vanSon@gmail.com +Helvetica 12 +Courier 12 This program is free software: you can redistribute it and/or modify +Courier 12 it under the terms of the GNU General Public License as published by +Courier 12 the Free Software Foundation, either version 3 of the License, or +Courier 12 (at your option) any later version. +Courier 12 +Courier 12 This program is distributed in the hope that it will be useful, +Courier 12 but WITHOUT ANY WARRANTY; without even the implied warranty of +Courier 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +Courier 12 GNU General Public License for more details. +Courier 12 +Courier 12 You should have received a copy of the GNU General Public License +Courier 12 along with this program. If not, see . +Courier 12 + diff --git a/Data/Credits_NL.Table b/Data/Credits_NL.Table new file mode 100644 index 0000000..ea9b272 --- /dev/null +++ b/Data/Credits_NL.Table @@ -0,0 +1,40 @@ +font size text +Helvetica 12 +Helvetica 16 SpeakGoodChinese version 2.0 +Helvetica 12 +Helvetica 12 For more information, visit our website: http://www.speakgoodchinese.org +Helvetica 12 Based on Praat (http://www.praat.org) +Helvetica 12 +Helvetica 12 SpeakGoodChinese was supported by grant 6046 from the Digitale Universiteit +Helvetica 12 The SpeakGoodChinese Team +Helvetica 12 * ##Guanqin Chen# (HRO) - Founder and project manager, Language and Teaching +Helvetica 12 * ##Zongyan Chen# (HvA) - Language and Teaching +Helvetica 12 * ##Eveline van Hagen# (Fontys) - Language and Teaching +Helvetica 12 * ##Stefan de Konink# (UvA) - Lead programmer, User Interface +Helvetica 12 * ##Lifeng Liu# (HRO) - Language assistant +Helvetica 12 * ##Rob van Son# (UvA) - Coordinator technical work, Speech technology, GUI +Helvetica 12 * ##Dennis Vierkant# (UT) - User Interface and Language +Helvetica 12 * ##David Weenink# (UvA) - Praat programming, Algorithms We would like to thank +Helvetica 12 +Helvetica 12 We would like to thank Paul Boersma (UvA) for his help with Praat linking and Tristian van Berkom +Helvetica 12 for additional help with the localization code. J.E. Raaijmakers, R. van Rijsselt and S. Verhagen +Helvetica 12 for feedback on the GUI and Praat library integration on Windows. +Helvetica 12 We are very grateful for all the practical, organisational, and financial support from the staff +Helvetica 12 and board of the Digitale Universiteit. +Helvetica 12 +Helvetica 12 Created and Copyrights 2007-2010 by Rob van Son (ACLC/UvA) - R.J.J.H.vanSon@gmail.com +Helvetica 12 +Courier 12 This program is free software: you can redistribute it and/or modify +Courier 12 it under the terms of the GNU General Public License as published by +Courier 12 the Free Software Foundation, either version 3 of the License, or +Courier 12 (at your option) any later version. +Courier 12 +Courier 12 This program is distributed in the hope that it will be useful, +Courier 12 but WITHOUT ANY WARRANTY; without even the implied warranty of +Courier 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +Courier 12 GNU General Public License for more details. +Courier 12 +Courier 12 You should have received a copy of the GNU General Public License +Courier 12 along with this program. If not, see . +Courier 12 + diff --git a/sgc2.praat b/sgc2.praat index f23c5fa..4d925de 100644 --- a/sgc2.praat +++ b/sgc2.praat @@ -984,3 +984,95 @@ procedure loadTable .tableName$ call Create'.tableName$' endif endproc + +# Create a pop-up window with text from a Text Table +procedure write_text_table .table$ + .xleft = 10 + .xright = 90 + .ylow = 20 + .yhigh = 85 + .lineHeight = 2.5 + + # Get table with text and longest line + call loadTable '.table$' + .instructionText = selected() + .numLines = Get number of rows + .instructionFontSize = 14 + .referenceText$ = "" + .maxlenght = 0 + .maxLine = 0 + .maxFontSize = 0 + .maxWidth = 0 + for .l to .numLines + select '.instructionText' + .currentText$ = Get value... '.l' text + .font$ = Get value... '.l' font + .fontSize = Get value... '.l' size + call set_font_size '.fontSize' + .textWidth = demo Text width (wc)... '.currentText$' + if .fontSize > .maxFontSize + .maxFontSize = .fontSize + endif + if .textWidth > .maxWidth + .maxWidth = .textWidth + .instructionFontSize = .fontSize + .maxLine = .l + endif + endfor + select '.instructionText' + .referenceText$ = Get value... '.maxLine' text + .maxLineFont$ = Get value... '.maxLine' font + .instructionFontSize = Get value... '.maxLine' size + call set_font_size '.maxFontSize' + + # Adapt size of button to length of text + .maxWidth = (.xright - .xleft) - 4 + .origFontSize = .instructionFontSize + call adjustFontSizeOnWidth '.instructionFontSize' '.maxWidth' '.referenceText$' + call adjustFontSizeOnHeight '.maxFontSize' '.lineHeight' + .instructionFontSize = min(adjustFontSizeOnWidth.newFontSize, adjustFontSizeOnHeight.newFontSize) + if adjustFontSizeOnWidth.diff > 0 + .xright += adjustFontSizeOnWidth.diff/4 + .xleft -= 3*adjustFontSizeOnWidth.diff/4 + endif + call set_font_size '.instructionFontSize' + .fontSizeFactor = .instructionFontSize / .origFontSize + + .numRows = Get number of rows + # Calculate length from number of lines. + .dy = .lineHeight + .midY = .yhigh - (.yhigh - .ylow)/2 + .yhigh = .midY + (.numRows+1) * .dy / 2 + .ylow = .yhigh - (.numRows+1) * .dy + .textleft = .xleft + 2 + + demo Line width... 8 + demo Colour... {0.5,0.5,1} + demo Paint rectangle... {0.9,0.9,1} '.xleft' '.xright' '.ylow' '.yhigh' + demo Draw rectangle... '.xleft' '.xright' '.ylow' '.yhigh' + demo Line width... 'defaultLineWidth' + demo Black + .ytext = .yhigh - 2 - .dy + for .i to .numRows + select '.instructionText' + .font$ = Get value... '.i' font + .fontSize = Get value... '.i' size + .font$ = extractWord$(.font$, "") + # Scale font + .fontSize = floor(.fontSize*.fontSizeFactor) + if .fontSize < 6 + .fontSize = 6 + endif + .line$ = Get value... '.i' text + # Clean up text + demo Text special... '.textleft' Left '.ytext' Bottom '.font$' '.fontSize' 0 '.line$' + .ytext -= .dy + endfor + demoShow() + call set_font_size 'defaultFontSize' + + select '.instructionText' + Remove +endproc + + -- 2.11.4.GIT