diff options
Diffstat (limited to 'demos/mobile')
205 files changed, 12750 insertions, 0 deletions
diff --git a/demos/mobile/guitartuner/guitartuner.pro b/demos/mobile/guitartuner/guitartuner.pro new file mode 100644 index 0000000..6283530 --- /dev/null +++ b/demos/mobile/guitartuner/guitartuner.pro @@ -0,0 +1,89 @@ +#------------------------------------------------- +# +# Project created by QtCreator 2010-10-22T14:28:56 +# +#------------------------------------------------- + +QT += core gui + +TARGET = guitartuner +TEMPLATE = app + +ICON = images/guitartuner_icon.svg + +SOURCES += src/main.cpp\ + src/guitartuner.cpp \ + src/voicegenerator.cpp \ + src/voiceanalyzer.cpp \ + src/guitartunerui.cpp \ + src/fastfouriertransformer.cpp + +HEADERS += src/guitartuner.h \ + src/voicegenerator.h \ + src/voiceanalyzer.h \ + src/constants.h \ + src/guitartunerui.h \ + src/fastfouriertransformer.h + +FORMS += src/guitartunerui.ui + +VERSION = 1.2.0 + +symbian { + INCLUDEPATH += /epoc32/include/mmf/common + INCLUDEPATH += /epoc32/include/mmf/server + LIBS += -lmmfdevsound + TARGET.UID3 = 0xEC46D2C8 + # TARGET.CAPABILITY += + # TARGET.EPOCSTACKSIZE = 0x14000 + # TARGET.EPOCHEAPSIZE = 0x020000 0x1000000 +} + +RESOURCES += \ + guitartuner.qrc + +# Avoid auto screen rotation +DEFINES += ORIENTATIONLOCK + +symbian { + contains(DEFINES, ORIENTATIONLOCK):LIBS += -lavkon -leikcore -leiksrv -lcone +} + + +# Add mobility into Qt's CONFIG, and add multimedia into MOBILITY. + +win32 { + QT += multimedia + RC_FILE = src/guitartuner.rc +} +else { + CONFIG += mobility + MOBILITY += multimedia +} + +symbian { + TARGET.CAPABILITY = UserEnvironment +} + +# Add declarative module +QT += declarative + +OTHER_FILES += \ + src/application.qml \ + src/mycomponents/Adjuster.qml \ + src/mycomponents/adjustbars.js \ + src/mycomponents/ToggleButton.qml + +OTHER_FILES += \ + src/mycomponents/NotesModel.qml \ + src/mycomponents/NoteButtonView.qml \ + src/mycomponents/Meter.qml + +unix:!symbian { + maemo5 { + target.path = /opt/usr/bin + } else { + target.path = /usr/local/bin + } + INSTALLS += target +} diff --git a/demos/mobile/guitartuner/guitartuner.qrc b/demos/mobile/guitartuner/guitartuner.qrc new file mode 100644 index 0000000..d8ba019 --- /dev/null +++ b/demos/mobile/guitartuner/guitartuner.qrc @@ -0,0 +1,43 @@ +<RCC> + <qresource prefix="/"> + <file>src/application.qml</file> + <file>src/mycomponents/adjustbars.js</file> + <file>src/mycomponents/Adjuster.qml</file> + <file>src/mycomponents/Meter.qml</file> + <file>src/mycomponents/NoteButtonView.qml</file> + <file>src/mycomponents/NotesModel.qml</file> + <file>src/mycomponents/ToggleButton.qml</file> + <file>src/mycomponents/images/meterBG.png</file> + <file>src/mycomponents/images/pointerShadow.png</file> + <file>src/mycomponents/images/sensitivity.png</file> + <file>src/mycomponents/images/tuner_a.png</file> + <file>src/mycomponents/images/tuner_a_on.png</file> + <file>src/mycomponents/images/tuner_b.png</file> + <file>src/mycomponents/images/tuner_b_on.png</file> + <file>src/mycomponents/images/tuner_d.png</file> + <file>src/mycomponents/images/tuner_d_on.png</file> + <file>src/mycomponents/images/tuner_e.png</file> + <file>src/mycomponents/images/tuner_e_on.png</file> + <file>src/mycomponents/images/tuner_g.png</file> + <file>src/mycomponents/images/tuner_g_on.png</file> + <file>src/mycomponents/images/voicemode_off.png</file> + <file>src/mycomponents/images/voicemode_on.png</file> + <file>src/mycomponents/images/volume.png</file> + <file>src/mycomponents/images/volume_off.png</file> + <file>src/mycomponents/images/guitartuner_skin.png</file> + <file>src/mycomponents/images/power.png</file> + <file>src/mycomponents/images/tuner_auto.png</file> + <file>src/mycomponents/images/tuner_auto_on.png</file> + <file>src/mycomponents/images/big_a.png</file> + <file>src/mycomponents/images/big_b.png</file> + <file>src/mycomponents/images/big_d.png</file> + <file>src/mycomponents/images/big_e.png</file> + <file>src/mycomponents/images/big_g.png</file> + <file>src/mycomponents/images/glowing_a.png</file> + <file>src/mycomponents/images/glowing_b.png</file> + <file>src/mycomponents/images/glowing_d.png</file> + <file>src/mycomponents/images/glowing_e.png</file> + <file>src/mycomponents/images/glowing_g.png</file> + <file>src/mycomponents/images/pointer.png</file> + </qresource> +</RCC> diff --git a/demos/mobile/guitartuner/images/guitartab.svg b/demos/mobile/guitartuner/images/guitartab.svg new file mode 100644 index 0000000..9d88d5d --- /dev/null +++ b/demos/mobile/guitartuner/images/guitartab.svg @@ -0,0 +1,174 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!-- Created with Inkscape (http://www.inkscape.org/) --> + +<svg + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:cc="http://creativecommons.org/ns#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + width="70.661781" + height="55.997791" + id="svg2" + version="1.1" + inkscape:version="0.47 r22583" + sodipodi:docname="guitartab.svg"> + <defs + id="defs4"> + <inkscape:perspective + sodipodi:type="inkscape:persp3d" + inkscape:vp_x="0 : 526.18109 : 1" + inkscape:vp_y="0 : 1000 : 0" + inkscape:vp_z="744.09448 : 526.18109 : 1" + inkscape:persp3d-origin="372.04724 : 350.78739 : 1" + id="perspective10" /> + <inkscape:perspective + id="perspective3604" + inkscape:persp3d-origin="0.5 : 0.33333333 : 1" + inkscape:vp_z="1 : 0.5 : 1" + inkscape:vp_y="0 : 1000 : 0" + inkscape:vp_x="0 : 0.5 : 1" + sodipodi:type="inkscape:persp3d" /> + <inkscape:perspective + id="perspective3632" + inkscape:persp3d-origin="0.5 : 0.33333333 : 1" + inkscape:vp_z="1 : 0.5 : 1" + inkscape:vp_y="0 : 1000 : 0" + inkscape:vp_x="0 : 0.5 : 1" + sodipodi:type="inkscape:persp3d" /> + <inkscape:perspective + id="perspective3632-4" + inkscape:persp3d-origin="0.5 : 0.33333333 : 1" + inkscape:vp_z="1 : 0.5 : 1" + inkscape:vp_y="0 : 1000 : 0" + inkscape:vp_x="0 : 0.5 : 1" + sodipodi:type="inkscape:persp3d" /> + <inkscape:perspective + id="perspective3632-9" + inkscape:persp3d-origin="0.5 : 0.33333333 : 1" + inkscape:vp_z="1 : 0.5 : 1" + inkscape:vp_y="0 : 1000 : 0" + inkscape:vp_x="0 : 0.5 : 1" + sodipodi:type="inkscape:persp3d" /> + <inkscape:perspective + id="perspective3632-8" + inkscape:persp3d-origin="0.5 : 0.33333333 : 1" + inkscape:vp_z="1 : 0.5 : 1" + inkscape:vp_y="0 : 1000 : 0" + inkscape:vp_x="0 : 0.5 : 1" + sodipodi:type="inkscape:persp3d" /> + <inkscape:perspective + id="perspective3632-2" + inkscape:persp3d-origin="0.5 : 0.33333333 : 1" + inkscape:vp_z="1 : 0.5 : 1" + inkscape:vp_y="0 : 1000 : 0" + inkscape:vp_x="0 : 0.5 : 1" + sodipodi:type="inkscape:persp3d" /> + <inkscape:perspective + id="perspective3690" + inkscape:persp3d-origin="0.5 : 0.33333333 : 1" + inkscape:vp_z="1 : 0.5 : 1" + inkscape:vp_y="0 : 1000 : 0" + inkscape:vp_x="0 : 0.5 : 1" + sodipodi:type="inkscape:persp3d" /> + <inkscape:perspective + id="perspective3712" + inkscape:persp3d-origin="0.5 : 0.33333333 : 1" + inkscape:vp_z="1 : 0.5 : 1" + inkscape:vp_y="0 : 1000 : 0" + inkscape:vp_x="0 : 0.5 : 1" + sodipodi:type="inkscape:persp3d" /> + </defs> + <sodipodi:namedview + id="base" + pagecolor="#ffffff" + bordercolor="#666666" + borderopacity="1.0" + inkscape:pageopacity="0.0" + inkscape:pageshadow="2" + inkscape:zoom="0.98994949" + inkscape:cx="343.43632" + inkscape:cy="198.00574" + inkscape:document-units="px" + inkscape:current-layer="layer1" + showgrid="false" + inkscape:window-width="1280" + inkscape:window-height="888" + inkscape:window-x="-4" + inkscape:window-y="-4" + inkscape:window-maximized="1" + showguides="true" + inkscape:guide-bbox="true" + borderlayer="true" /> + <metadata + id="metadata7"> + <rdf:RDF> + <cc:Work + rdf:about=""> + <dc:format>image/svg+xml</dc:format> + <dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> + <dc:title /> + </cc:Work> + </rdf:RDF> + </metadata> + <g + inkscape:label="Layer 1" + inkscape:groupmode="layer" + id="layer1" + transform="translate(-45.793001,-702.07386)"> + <rect + style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:#000000;stroke-width:1.96666431;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect3728" + width="68.695114" + height="54.031128" + x="46.776333" + y="703.05719" /> + <g + id="g3732" + transform="matrix(0.11166616,0,0,0.11166616,41.003771,673.42071)"> + <path + sodipodi:nodetypes="cc" + id="path2816" + d="m 133.63811,570.46864 0,-225.36571" + style="fill:none;stroke:#000000;stroke-width:17.61199951;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + sodipodi:nodetypes="cc" + id="path2816-7" + d="m 223.89631,570.46864 0,-225.36571" + style="fill:none;stroke:#000000;stroke-width:17.61199951;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + sodipodi:nodetypes="cc" + id="path2816-0" + d="m 314.15451,570.46864 0,-225.36571" + style="fill:none;stroke:#000000;stroke-width:17.61199951;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + sodipodi:nodetypes="cc" + id="path2816-4" + d="m 404.4127,570.46864 0,-225.36571" + style="fill:none;stroke:#000000;stroke-width:17.61199951;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + sodipodi:nodetypes="cc" + id="path2816-8" + d="m 494.6709,570.46864 0,-225.36571" + style="fill:none;stroke:#000000;stroke-width:17.61199951;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + sodipodi:nodetypes="cc" + id="path2816-45" + d="m 584.92911,570.46864 0,-225.36571" + style="fill:none;stroke:#000000;stroke-width:17.61199951;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + sodipodi:nodetypes="cc" + id="path2816-5" + d="m 124.89988,344.21478 468.77277,0" + style="fill:none;stroke:#000000;stroke-width:19.51578331;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + sodipodi:nodetypes="cc" + id="path2816-5-1" + d="m 125.76355,400.6818 467.80305,0" + style="fill:none;stroke:#000000;stroke-width:19.4955883;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + </g> + </g> +</svg> diff --git a/demos/mobile/guitartuner/images/guitartuner_icon.svg b/demos/mobile/guitartuner/images/guitartuner_icon.svg new file mode 100644 index 0000000..de7ebe0 --- /dev/null +++ b/demos/mobile/guitartuner/images/guitartuner_icon.svg @@ -0,0 +1,247 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Generator: Adobe Illustrator 15.0.2, SVG Export Plug-In --> +<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" [ + <!ENTITY ns_flows "http://ns.adobe.com/Flows/1.0/"> +]> +<svg version="1.1" + xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:a="http://ns.adobe.com/AdobeSVGViewerExtensions/3.0/" + x="0px" y="0px" width="128px" height="128px" viewBox="0 0 128 128" overflow="visible" enable-background="new 0 0 128 128" + xml:space="preserve"> +<defs> +</defs> +<rect x="0" display="none" fill="#1A171B" width="128" height="128"/> +<circle fill="#13235B" cx="64" cy="64" r="47"/> +<g> + <g> + <path fill="#F29400" d="M14.352,113.699c0,0-13.927-13.928-3.122-24.732c7.203-7.205,11.706-2.701,15.308-6.305 + c3.602-3.601,1.417-6.729,5.28-10.84c7.547-8.035,15.842,3.149,15.842,3.149l4.765,4.765l-7.204,7.204 + c0,0,5.134,7.943,12.338,0.74c-3.827,10.578-9.411,9.39-13.014,12.99c-3.602,3.603,0.854,8.058-6.303,15.31 + C27.508,126.855,14.352,113.699,14.352,113.699z"/> + </g> + <defs> + <filter id="Adobe_OpacityMaskFilter" filterUnits="userSpaceOnUse" x="7.122" y="68.918" width="50.437" height="51.368"> + + <feColorMatrix type="matrix" values="-1 0 0 0 1 0 -1 0 0 1 0 0 -1 0 1 0 0 0 1 0" color-interpolation-filters="sRGB" result="source"/> + </filter> + </defs> + <mask maskUnits="userSpaceOnUse" x="7.122" y="68.918" width="50.437" height="51.368" id="SVGID_1_"> + <g filter="url(#Adobe_OpacityMaskFilter)"> + + <image overflow="visible" width="55" height="57" xlink:href="data:image/jpeg;base64,/9j/4AAQSkZJRgABAgEASABIAAD/7AARRHVja3kAAQAEAAAAHgAA/+4AIUFkb2JlAGTAAAAAAQMA +EAMCAwYAAAG8AAACPgAAAr//2wCEABALCwsMCxAMDBAXDw0PFxsUEBAUGx8XFxcXFx8eFxoaGhoX +Hh4jJSclIx4vLzMzLy9AQEBAQEBAQEBAQEBAQEABEQ8PERMRFRISFRQRFBEUGhQWFhQaJhoaHBoa +JjAjHh4eHiMwKy4nJycuKzU1MDA1NUBAP0BAQEBAQEBAQEBAQP/CABEIADkANwMBIgACEQEDEQH/ +xAB9AAABBQEBAAAAAAAAAAAAAAAAAgQFBgcBAwEBAAAAAAAAAAAAAAAAAAAAABAAAgMAAgICAwAA +AAAAAAAAAgMBBAUABhBAMBEhEiMRAAICAQMFAQAAAAAAAAAAAAECABEhEEESIDFRIgMwEgEAAAAA +AAAAAAAAAAAAAABA/9oADAMBAAIRAxEAAADPwAc+F5Kkx0alEcAdmuaSVq5PFkFles5qQR0J/T8X +0IuyGbQrdAm4IAAcNwsnjAgpIAAf/9oACAECAAEFAPQ//9oACAEDAAEFAPQ//9oACAEBAAEFAPNa +k2xx+W5UTExPlYSw8bI/jezBFerWBTeCJGVDrjrEZPT1qZUzgSvZT+qtc2zc516mL25WcuABIBHN +loQvbZXln3+eruEG5bRJfGnAB27WJKzYbC5TslWfh7YECtNZDoagQvst6LDfNW8+qVbtBCN3sRtF +jDYfw//aAAgBAgIGPwAH/9oACAEDAgY/AAf/2gAIAQEBBj8A1tRichkSj36FRcljUW12hsQlcHQK +osnsIC952EH0ZbPkwCo1DaOrigD66cmF5gxMDRrMY4Jl7Tie9wVoTGCnJwIWc2Tov0U43i+0u4aM +4A3m+i0bHiU5IMKoSSYXc2T+X//Z" transform="matrix(1 0 0 1 5.0005 66)"> + </image> + </g> + </mask> + <g mask="url(#SVGID_1_)"> + <path fill="#B20000" d="M14.352,113.699c0,0-13.927-13.928-3.122-24.732c7.203-7.205,11.706-2.701,15.308-6.305 + c3.602-3.601,1.417-6.729,5.28-10.84c7.547-8.035,15.842,3.149,15.842,3.149l4.765,4.765l-7.204,7.204 + c0,0,5.134,7.943,12.338,0.74c-3.827,10.578-9.411,9.39-13.014,12.99c-3.602,3.603,0.854,8.058-6.303,15.31 + C27.508,126.855,14.352,113.699,14.352,113.699z"/> + </g> +</g> +<g> + <path fill="#FFEDB8" d="M37.791,69.168c5.189,0,9.624,5.894,9.692,5.98l4.588,4.588l-7.027,7.027l-0.143,0.143l0.11,0.17 + c0.102,0.158,2.55,3.875,6.503,3.875c1.808,0,3.63-0.791,5.427-2.352c-2.541,6.327-5.777,7.936-8.649,9.362 + c-1.422,0.707-2.765,1.374-3.924,2.532c-1.562,1.562-1.672,3.261-1.8,5.227c-0.171,2.633-0.384,5.909-4.504,10.084 + c-2.771,2.808-5.958,4.231-9.472,4.231c-7.46,0-14-6.448-14.064-6.514c-0.137-0.138-13.625-13.877-3.122-24.379 + c4.152-4.153,7.301-4.348,10.078-4.519c1.97-0.122,3.67-0.227,5.229-1.786c1.829-1.829,2.218-3.585,2.595-5.284 + c0.384-1.735,0.782-3.529,2.69-5.562C33.761,70.118,35.709,69.168,37.791,69.168 M37.791,68.918c-1.932,0-3.979,0.781-5.974,2.904 + c-3.862,4.11-1.678,7.239-5.28,10.84c-3.602,3.604-8.104-0.9-15.308,6.305c-10.805,10.805,3.122,24.732,3.122,24.732 + s6.586,6.587,14.241,6.587c3.164,0,6.51-1.126,9.649-4.306c7.157-7.252,2.701-11.707,6.303-15.31 + c3.603-3.601,9.187-2.412,13.014-12.99c-2.248,2.247-4.293,3.021-6.044,3.021c-3.862,0-6.293-3.761-6.293-3.761l7.204-7.204 + l-4.765-4.765C47.66,74.972,43.17,68.918,37.791,68.918L37.791,68.918z"/> +</g> +<rect x="35.983" y="67.296" transform="matrix(-0.7071 0.7071 -0.7071 -0.7071 146.0415 81.7395)" fill="#41281B" width="40.217" height="7.64"/> +<rect x="35.697" y="84.509" transform="matrix(-0.7073 0.707 -0.707 -0.7073 128.185 124.851)" fill="#ECEDED" width="5.092" height="8.913"/> +<rect x="27.593" y="92.612" transform="matrix(-0.7072 0.7071 -0.7071 -0.7072 120.0864 144.402)" fill="#ECEDED" width="5.092" height="8.914"/> +<rect x="24.55" y="96.293" transform="matrix(-0.7071 0.7071 -0.7071 -0.7071 115.1376 156.3543)" fill="#F6F6F6" width="1.273" height="11.46"/> +<rect x="26.351" y="94.491" transform="matrix(-0.7071 0.7071 -0.7071 -0.7071 116.9377 152.0052)" fill="#F6F6F6" width="1.273" height="11.461"/> +<line fill="none" stroke="#FFFFFF" stroke-width="0.15" stroke-miterlimit="10" x1="23.499" y1="99.433" x2="66.495" y2="56.438"/> +<line fill="none" stroke="#FFFFFF" stroke-width="0.15" stroke-miterlimit="10" x1="28" y1="103.934" x2="70.997" y2="60.941"/> +<line fill="none" stroke="#FFFFFF" stroke-width="0.15" stroke-miterlimit="10" x1="27.101" y1="103.034" x2="70.096" y2="60.04"/> +<line fill="none" stroke="#FFFFFF" stroke-width="0.15" stroke-miterlimit="10" x1="26.2" y1="102.134" x2="69.196" y2="59.139"/> +<line fill="none" stroke="#FFFFFF" stroke-width="0.15" stroke-miterlimit="10" x1="25.3" y1="101.233" x2="68.295" y2="58.239"/> +<line fill="none" stroke="#FFFFFF" stroke-width="0.15" stroke-miterlimit="10" x1="24.4" y1="100.333" x2="67.395" y2="57.339"/> +<circle fill="#1A171B" cx="26.908" cy="113.596" r="1.761"/> +<path fill="#1A171B" d="M33.138,107.366c0.688,0.687,0.688,1.804,0,2.493c-0.688,0.686-1.804,0.686-2.492,0 + c-0.688-0.689-0.688-1.807,0-2.493C31.334,106.678,32.45,106.678,33.138,107.366z"/> +<circle fill="#FFEDB8" cx="36.848" cy="75.131" r="1.762"/> +<circle fill="#1A171B" cx="32.31" cy="115.397" r="1.762"/> +<path fill="#1A171B" d="M38.54,109.167c0.689,0.687,0.689,1.804,0,2.493c-0.688,0.686-1.804,0.686-2.492,0 + c-0.688-0.689-0.688-1.807,0-2.493C36.736,108.479,37.852,108.479,38.54,109.167z"/> +<g> + <g> + <path fill="#ECEDED" d="M105.895,10.52l2.704,2.702L70.764,51.056c0,0-2.702,2.702,0,5.404c2.704,2.702,5.405,0,5.405,0 + l37.833-37.833l2.704,2.702c0,0-35.132,35.131-37.835,37.833c-2.702,2.702-8.107,2.702-10.81,0s-2.702-8.106,0-10.809 + C70.765,45.649,105.895,10.52,105.895,10.52z"/> + </g> + <defs> + <filter id="Adobe_OpacityMaskFilter_1_" filterUnits="userSpaceOnUse" x="66.036" y="10.52" width="50.671" height="50.669"> + + <feColorMatrix type="matrix" values="-1 0 0 0 1 0 -1 0 0 1 0 0 -1 0 1 0 0 0 1 0" color-interpolation-filters="sRGB" result="source"/> + </filter> + </defs> + <mask maskUnits="userSpaceOnUse" x="66.036" y="10.52" width="50.671" height="50.669" id="SVGID_2_"> + <g filter="url(#Adobe_OpacityMaskFilter_1_)"> + + <image overflow="visible" width="55" height="56" xlink:href="data:image/jpeg;base64,/9j/4AAQSkZJRgABAgEASABIAAD/7AARRHVja3kAAQAEAAAAHgAA/+4AIUFkb2JlAGTAAAAAAQMA +EAMCAwYAAAGyAAACNwAAA9T/2wCEABALCwsMCxAMDBAXDw0PFxsUEBAUGx8XFxcXFx8eFxoaGhoX +Hh4jJSclIx4vLzMzLy9AQEBAQEBAQEBAQEBAQEABEQ8PERMRFRISFRQRFBEUGhQWFhQaJhoaHBoa +JjAjHh4eHiMwKy4nJycuKzU1MDA1NUBAP0BAQEBAQEBAQEBAQP/CABEIADgANwMBIgACEQEDEQH/ +xACCAAEBAQADAAAAAAAAAAAAAAAABgQDBQcBAQAAAAAAAAAAAAAAAAAAAAAQAQEBAAIDAQEAAAAA +AAAAAAUEBhADACBAAQIRAAIBAgQEBgIDAQAAAAAAAAECAxEEACFREjHBQgUQIGEyUhNBFZEiIwYS +AQAAAAAAAAAAAAAAAAAAAED/2gAMAwEAAhEDEQAAAPPwDcOwp4w61WCTNwt0YL95scjGN1vxSIv3 +mwzgBUdyENnAAD//2gAIAQIAAQUA+D//2gAIAQMAAQUA+D//2gAIAQEAAQUA9Bx7GLNSHCL3+g49 +jFiKJuMNONS0CLmRkOQ4HHsYsRRNxhppqWgSqqJwxPatd3JeDj2MWIom4w001LQJVVE4Ym66pCrw +cexixFE3GGmmpaBKqonDE3XVIVcZ+r9JwppqWgSqqJwxN11SFXOV1/8ABHR3bgAvouuqQq9P/9oA +CAECAgY/AAf/2gAIAQMCBj8AB//aAAgBAQEGPwDyLaWi1Jzdz7UXU4ht7e4+2bb/ALJxofl6eVbS +0WpObufai6nH6ztlJO4yCskhzNT1vyGPrjrJNId00zZhQepuQx22xhudz3kkcMgNNw3sF3j+fFbS +0WpObufai6nH6ztlJO4yCskhzNT1vyGPrjrJNId00zZhQepuQwLe3AlvpRkOt3+TaAYXuksm+6SR +ZVY8AUO5QBoPBbS0WpObufai6nH6ztlJO4yCskhzNT1vyGPrjrJNId00zZhQepuQwLe3AlvpRkOt +3+TaAYe7u3Mk0hqSeAGg9PBbS0WpObufai6nH6ztlJO4yCskhzNT1vyGPrjrJNId00zZhQepuQwL +e3AlvpRkOt3+TaAYe7u3Mk0hqSeAGg9PGfuVrFW6ZnBYCpru2Bm9Fx9cdZJpDummbMKD1NyGBb24 +Et9KMh1u/wAm0Aw93duZJpDUk8ANB6eRu33sJnspGJyoSm7j/X8j84ZP+fsgJJM2IT6lB9cqnD3d +25kmkNSTwA0Hp5f/2Q==" transform="matrix(1 0 0 1 64.0005 8)"> + </image> + </g> + </mask> + <g opacity="0.77" mask="url(#SVGID_2_)"> + <path fill="#1C1B1B" d="M105.895,10.52l2.704,2.702L70.764,51.056c0,0-2.702,2.702,0,5.404c2.704,2.702,5.405,0,5.405,0 + l37.833-37.833l2.704,2.702c0,0-35.132,35.131-37.835,37.833c-2.702,2.702-8.107,2.702-10.81,0s-2.702-8.106,0-10.809 + C70.765,45.649,105.895,10.52,105.895,10.52z"/> + </g> +</g> +<line fill="none" stroke="#FFFFFF" stroke-width="0.25" stroke-miterlimit="10" x1="40.044" y1="81.762" x2="45.447" y2="87.166"/> +<line fill="none" stroke="#FFFFFF" stroke-width="0.25" stroke-miterlimit="10" x1="40.966" y1="80.84" x2="46.37" y2="86.241"/> +<line fill="none" stroke="#FFFFFF" stroke-width="0.25" stroke-miterlimit="10" x1="41.96" y1="79.846" x2="47.363" y2="85.248"/> +<line fill="none" stroke="#FFFFFF" stroke-width="0.25" stroke-miterlimit="10" x1="43.168" y1="78.639" x2="48.57" y2="84.042"/> +<line fill="none" stroke="#FFFFFF" stroke-width="0.25" stroke-miterlimit="10" x1="44.587" y1="77.219" x2="49.99" y2="82.623"/> +<line fill="none" stroke="#FFFFFF" stroke-width="0.25" stroke-miterlimit="10" x1="46.006" y1="75.801" x2="51.41" y2="81.203"/> +<line fill="none" stroke="#FFFFFF" stroke-width="0.25" stroke-miterlimit="10" x1="47.285" y1="74.522" x2="52.688" y2="79.925"/> +<line fill="none" stroke="#FFFFFF" stroke-width="0.25" stroke-miterlimit="10" x1="48.847" y1="72.961" x2="54.249" y2="78.362"/> +<line fill="none" stroke="#FFFFFF" stroke-width="0.25" stroke-miterlimit="10" x1="50.621" y1="71.185" x2="56.023" y2="76.589"/> +<line fill="none" stroke="#FFFFFF" stroke-width="0.25" stroke-miterlimit="10" x1="52.489" y1="69.329" x2="57.891" y2="74.731"/> +<line fill="none" stroke="#FFFFFF" stroke-width="0.25" stroke-miterlimit="10" x1="54.405" y1="67.4" x2="59.709" y2="72.704"/> +<line fill="none" stroke="#FFFFFF" stroke-width="0.25" stroke-miterlimit="10" x1="56.517" y1="65.392" x2="61.821" y2="70.696"/> +<line fill="none" stroke="#FFFFFF" stroke-width="0.25" stroke-miterlimit="10" x1="59.166" y1="62.744" x2="64.469" y2="68.047"/> +<line fill="none" stroke="#FFFFFF" stroke-width="0.25" stroke-miterlimit="10" x1="61.883" y1="60.026" x2="67.187" y2="65.329"/> +<line fill="none" stroke="#FFFFFF" stroke-width="0.25" stroke-miterlimit="10" x1="64.902" y1="57.007" x2="70.206" y2="62.31"/> +<g display="none"> + <g display="inline"> + <path fill="#F29400" d="M0,24.468C0,24.468,0,9,12,9c8,0,8,5,12,5s4.525-2.95,8.952-3.088C41.605,10.642,40,21.458,40,21.458 + v5.291h-8c0,0-1.56,7.262,6.44,7.262C30.44,37.762,28,34,24,34c-4,0-4,4.948-12,5C0,39.078,0,24.468,0,24.468z"/> + </g> + <defs> + <filter id="Adobe_OpacityMaskFilter_2_" filterUnits="userSpaceOnUse" x="0" y="9" width="40.118" height="30"> + + <feColorMatrix type="matrix" values="-1 0 0 0 1 0 -1 0 0 1 0 0 -1 0 1 0 0 0 1 0" color-interpolation-filters="sRGB" result="source"/> + </filter> + </defs> + <mask maskUnits="userSpaceOnUse" x="0" y="9" width="40.118" height="30" id="SVGID_3_" display="inline"> + <g filter="url(#Adobe_OpacityMaskFilter_2_)"> + + <image overflow="visible" width="46" height="35" xlink:href="data:image/jpeg;base64,/9j/4AAQSkZJRgABAgEASABIAAD/7AARRHVja3kAAQAEAAAAHgAA/+4AIUFkb2JlAGTAAAAAAQMA +EAMCAwYAAAGrAAACBgAAAl3/2wCEABALCwsMCxAMDBAXDw0PFxsUEBAUGx8XFxcXFx8eFxoaGhoX +Hh4jJSclIx4vLzMzLy9AQEBAQEBAQEBAQEBAQEABEQ8PERMRFRISFRQRFBEUGhQWFhQaJhoaHBoa +JjAjHh4eHiMwKy4nJycuKzU1MDA1NUBAP0BAQEBAQEBAQEBAQP/CABEIACMALgMBIgACEQEDEQH/ +xAB+AAABBQEBAAAAAAAAAAAAAAAAAgMFBgcEAQEBAAAAAAAAAAAAAAAAAAAAABAAAgMAAgIDAQAA +AAAAAAAAAgMBBAUREzAGECAxFBEAAgEEAQMFAAAAAAAAAAAAAAERIUECElEQMYEgIkIDExIBAAAA +AAAAAAAAAAAAAAAAMP/aAAwDAQACEQMRAAAAoEknQjPuDXogztq4Vo7NJyW2mgQdegRyGUyCwPEg +AB//2gAIAQIAAQUA8P8A/9oACAEDAAEFAPD/AP/aAAgBAQABBQARkpr4r3DYxLKR6W8zUfA8TzjV +4dZzMwJB2Mshs4aQm9VWsZAf7vXigbGW4IBllcDp3VwOtrlL+0u2nYmu6jvgIXPZxALHsLnTYdDi ++A/D+n//2gAIAQICBj8AH//aAAgBAwIGPwAf/9oACAEBAQY/AFjipbJdzZLY10c8QbPEi5WsCoVx +G9UNJGONmxzyI7jhmX1pU5P1uLNdri9w4yHRwbX6/LwX8+j/2Q==" transform="matrix(1 0 0 1 -2.9995 6)"> + </image> + </g> + </mask> + <g display="inline" mask="url(#SVGID_3_)"> + <path fill="#B20000" d="M0,24.468C0,24.468,0,9,12,9c8,0,8,5,12,5s4.525-2.95,8.952-3.088C41.605,10.642,40,21.458,40,21.458 + v5.291h-8c0,0-1.56,7.262,6.44,7.262C30.44,37.762,28,34,24,34c-4,0-4,4.948-12,5C0,39.078,0,24.468,0,24.468z"/> + </g> +</g> +<g display="none"> + <path display="inline" fill="#FFEDB8" d="M12,9.25c4.592,0,6.439,1.633,8.07,3.075c1.169,1.033,2.179,1.926,3.93,1.926 + c2.047,0,3.246-0.764,4.405-1.502c1.171-0.746,2.382-1.518,4.555-1.585c0.104-0.003,0.207-0.005,0.308-0.005 + c2.021,0,3.606,0.649,4.712,1.931c2.537,2.939,1.782,8.28,1.771,8.37V26.5H32h-0.202l-0.042,0.197 + c-0.028,0.13-0.663,3.21,1.127,5.426c0.979,1.211,2.483,1.913,4.481,2.093c-1.956,0.813-3.706,1.21-5.323,1.21 + c-1.76,0-3.121-0.458-4.438-0.9C26.416,34.126,25.295,33.75,24,33.75c-1.755,0-2.766,0.888-3.937,1.916 + c-1.631,1.432-3.479,3.054-8.064,3.084l-0.095,0C0.388,38.75,0.25,24.61,0.25,24.468C0.25,24.315,0.391,9.25,12,9.25 M12,9 + C0,9,0,24.468,0,24.468S-0.002,39,11.904,39c0.031,0,0.064,0,0.096,0c8-0.052,8-5,12-5c2.67,0,4.644,1.675,8.041,1.675 + c1.692,0,3.739-0.416,6.4-1.664c-8,0-6.44-7.262-6.44-7.262h8v-5.291c0,0,1.566-10.551-6.733-10.551 + c-0.104,0-0.209,0.001-0.316,0.005C28.525,11.05,28,14,24,14S20,9,12,9L12,9z"/> +</g> +<rect x="31.032" y="21" display="none" fill="#41281B" width="32.967" height="6"/> +<rect x="25" y="20.5" display="none" fill="#ECEDED" width="3.999" height="7"/> +<rect x="16.001" y="20.5" display="none" fill="#ECEDED" width="3.999" height="7"/> +<rect x="12" y="19.5" display="none" fill="#F6F6F6" width="1" height="9"/> +<rect x="14" y="19.5" display="none" fill="#F6F6F6" width="1" height="9"/> +<line display="none" fill="none" stroke="#FFFFFF" stroke-width="0.15" stroke-miterlimit="10" x1="13" y1="21.625" x2="60.75" y2="21.625"/> +<line display="none" fill="none" stroke="#FFFFFF" stroke-width="0.15" stroke-miterlimit="10" x1="13" y1="26.625" x2="60.75" y2="26.625"/> +<line display="none" fill="none" stroke="#FFFFFF" stroke-width="0.15" stroke-miterlimit="10" x1="13" y1="25.625" x2="60.75" y2="25.625"/> +<line display="none" fill="none" stroke="#FFFFFF" stroke-width="0.15" stroke-miterlimit="10" x1="13" y1="24.625" x2="60.75" y2="24.625"/> +<line display="none" fill="none" stroke="#FFFFFF" stroke-width="0.15" stroke-miterlimit="10" x1="13" y1="23.625" x2="60.75" y2="23.625"/> +<line display="none" fill="none" stroke="#FFFFFF" stroke-width="0.15" stroke-miterlimit="10" x1="13" y1="22.625" x2="60.75" y2="22.625"/> +<circle display="none" fill="#1A171B" cx="7.029" cy="31.382" r="1.384"/> +<circle display="none" fill="#1A171B" cx="12.564" cy="31.382" r="1.384"/> +<circle display="none" fill="#FFEDB8" cx="33.908" cy="15.543" r="1.384"/> +<circle display="none" fill="#1A171B" cx="9.029" cy="35.382" r="1.384"/> +<circle display="none" fill="#1A171B" cx="14.564" cy="35.382" r="1.384"/> +<g display="none"> + <g display="inline"> + <path fill="#ECEDED" d="M124,16v4H68c0,0-4,0-4,4s4,4,4,4h56v4c0,0-52,0-56,0s-8-4-8-8s4-8,8-8C72.001,16,124,16,124,16z"/> + </g> + <defs> + <filter id="Adobe_OpacityMaskFilter_3_" filterUnits="userSpaceOnUse" x="60" y="16" width="64" height="16"> + + <feColorMatrix type="matrix" values="-1 0 0 0 1 0 -1 0 0 1 0 0 -1 0 1 0 0 0 1 0" color-interpolation-filters="sRGB" result="source"/> + </filter> + </defs> + <mask maskUnits="userSpaceOnUse" x="60" y="16" width="64" height="16" id="SVGID_4_" display="inline"> + <g filter="url(#Adobe_OpacityMaskFilter_3_)"> + + <image overflow="visible" width="68" height="20" xlink:href="data:image/jpeg;base64,/9j/4AAQSkZJRgABAgEASABIAAD/7AARRHVja3kAAQAEAAAAHgAA/+4AIUFkb2JlAGTAAAAAAQMA +EAMCAwYAAAGtAAACAQAAAsf/2wCEABALCwsMCxAMDBAXDw0PFxsUEBAUGx8XFxcXFx8eFxoaGhoX +Hh4jJSclIx4vLzMzLy9AQEBAQEBAQEBAQEBAQEABEQ8PERMRFRISFRQRFBEUGhQWFhQaJhoaHBoa +JjAjHh4eHiMwKy4nJycuKzU1MDA1NUBAP0BAQEBAQEBAQEBAQP/CABEIABQARAMBIgACEQEDEQH/ +xACMAAEAAQUAAAAAAAAAAAAAAAAABQECAwQGAQEAAAAAAAAAAAAAAAAAAAAAEAABAgQGAwEAAAAA +AAAAAAAABicCAwQWMBIUBRUlAREXBxEAAAQCBwcEAwAAAAAAAAAAAAERAhIDITGR0hOjREFxBBQ0 +BRVRYUIzIqKDEgEAAAAAAAAAAAAAAAAAAAAw/9oADAMBAAIRAxEAAACH3tvnSTQwmUMJm2IoarAM +vTgoAC0OdB//2gAIAQIAAQUAwv/aAAgBAwABBQDC/9oACAEBAAEFAEmk4N2gnSvzWTMbUbUbUbUb +Uj+c5eq5VKwU28pKpQ6lp5lnqUs9SlnqUs9SlnqUiSKjh8aKq1e08nrXL9OUOUOUOUOUR/R8va8r +/9oACAECAgY/AC//2gAIAQMCBj8AL//aAAgBAQEGPwB3cO4Pwu3S1KtDeZV07CIHLN815trcw5jm +nucVA1GaNRmjUZo1GaNRmg4Mddn2j5eNi94oUtrHEdjZOKXxZG80UyP8jiadCKXqIC4TGJFjlOI2 +/tCOgmWtvDoJlrbw6CZa28OgmWtvDoJlrbwV3ATCLe28OSwz5lYcOhVRQzxUfN0w4dabV2JvGoT+ +Q1GUNRlDUZQ1GUNRlA48dNv1D5eSi9ooksqH/9k=" transform="matrix(1 0 0 1 58.0005 14)"> + </image> + </g> + </mask> + <g display="inline" opacity="0.75" mask="url(#SVGID_4_)"> + <path fill="#1C1B1B" d="M124,16v4H68c0,0-4,0-4,4s4,4,4,4h56v4c0,0-52,0-56,0s-8-4-8-8s4-8,8-8C72.001,16,124,16,124,16z"/> + </g> +</g> +<line display="none" fill="none" stroke="#FFFFFF" stroke-width="0.25" stroke-miterlimit="10" x1="32" y1="21" x2="32" y2="27"/> +<line display="none" fill="none" stroke="#FFFFFF" stroke-width="0.25" stroke-miterlimit="10" x1="33.025" y1="21" x2="33.025" y2="27"/> +<line display="none" fill="none" stroke="#FFFFFF" stroke-width="0.25" stroke-miterlimit="10" x1="34.129" y1="21" x2="34.129" y2="27"/> +<line display="none" fill="none" stroke="#FFFFFF" stroke-width="0.25" stroke-miterlimit="10" x1="35.469" y1="21" x2="35.469" y2="27"/> +<line display="none" fill="none" stroke="#FFFFFF" stroke-width="0.25" stroke-miterlimit="10" x1="37.046" y1="21" x2="37.046" y2="27"/> +<line display="none" fill="none" stroke="#FFFFFF" stroke-width="0.25" stroke-miterlimit="10" x1="38.623" y1="21" x2="38.623" y2="27"/> +<line display="none" fill="none" stroke="#FFFFFF" stroke-width="0.25" stroke-miterlimit="10" x1="40.042" y1="21" x2="40.042" y2="27"/> +<line display="none" fill="none" stroke="#FFFFFF" stroke-width="0.25" stroke-miterlimit="10" x1="41.776" y1="21" x2="41.776" y2="27"/> +<line display="none" fill="none" stroke="#FFFFFF" stroke-width="0.25" stroke-miterlimit="10" x1="43.747" y1="21" x2="43.747" y2="27"/> +<line display="none" fill="none" stroke="#FFFFFF" stroke-width="0.25" stroke-miterlimit="10" x1="46.033" y1="21" x2="46.033" y2="27"/> +<line display="none" fill="none" stroke="#FFFFFF" stroke-width="0.25" stroke-miterlimit="10" x1="48.635" y1="21" x2="48.635" y2="27"/> +<line display="none" fill="none" stroke="#FFFFFF" stroke-width="0.25" stroke-miterlimit="10" x1="51.315" y1="21" x2="51.315" y2="27"/> +<line display="none" fill="none" stroke="#FFFFFF" stroke-width="0.25" stroke-miterlimit="10" x1="54.311" y1="21" x2="54.311" y2="27"/> +<line display="none" fill="none" stroke="#FFFFFF" stroke-width="0.25" stroke-miterlimit="10" x1="57.385" y1="21" x2="57.385" y2="27"/> +</svg> diff --git a/demos/mobile/guitartuner/images/inputMode.svg b/demos/mobile/guitartuner/images/inputMode.svg new file mode 100644 index 0000000..f95991a --- /dev/null +++ b/demos/mobile/guitartuner/images/inputMode.svg @@ -0,0 +1,161 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!-- Created with Inkscape (http://www.inkscape.org/) --> + +<svg + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:cc="http://creativecommons.org/ns#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + width="690.84283" + height="597.90881" + id="svg2" + version="1.1" + inkscape:version="0.47 r22583" + sodipodi:docname="inputMode.svg"> + <defs + id="defs4"> + <inkscape:perspective + sodipodi:type="inkscape:persp3d" + inkscape:vp_x="0 : 526.18109 : 1" + inkscape:vp_y="0 : 1000 : 0" + inkscape:vp_z="744.09448 : 526.18109 : 1" + inkscape:persp3d-origin="372.04724 : 350.78739 : 1" + id="perspective10" /> + <inkscape:perspective + id="perspective3604" + inkscape:persp3d-origin="0.5 : 0.33333333 : 1" + inkscape:vp_z="1 : 0.5 : 1" + inkscape:vp_y="0 : 1000 : 0" + inkscape:vp_x="0 : 0.5 : 1" + sodipodi:type="inkscape:persp3d" /> + <inkscape:perspective + id="perspective3622" + inkscape:persp3d-origin="0.5 : 0.33333333 : 1" + inkscape:vp_z="1 : 0.5 : 1" + inkscape:vp_y="0 : 1000 : 0" + inkscape:vp_x="0 : 0.5 : 1" + sodipodi:type="inkscape:persp3d" /> + <inkscape:perspective + id="perspective3622-7" + inkscape:persp3d-origin="0.5 : 0.33333333 : 1" + inkscape:vp_z="1 : 0.5 : 1" + inkscape:vp_y="0 : 1000 : 0" + inkscape:vp_x="0 : 0.5 : 1" + sodipodi:type="inkscape:persp3d" /> + <inkscape:perspective + id="perspective3653" + inkscape:persp3d-origin="0.5 : 0.33333333 : 1" + inkscape:vp_z="1 : 0.5 : 1" + inkscape:vp_y="0 : 1000 : 0" + inkscape:vp_x="0 : 0.5 : 1" + sodipodi:type="inkscape:persp3d" /> + <inkscape:perspective + id="perspective3653-4" + inkscape:persp3d-origin="0.5 : 0.33333333 : 1" + inkscape:vp_z="1 : 0.5 : 1" + inkscape:vp_y="0 : 1000 : 0" + inkscape:vp_x="0 : 0.5 : 1" + sodipodi:type="inkscape:persp3d" /> + <inkscape:perspective + id="perspective3653-8" + inkscape:persp3d-origin="0.5 : 0.33333333 : 1" + inkscape:vp_z="1 : 0.5 : 1" + inkscape:vp_y="0 : 1000 : 0" + inkscape:vp_x="0 : 0.5 : 1" + sodipodi:type="inkscape:persp3d" /> + </defs> + <sodipodi:namedview + id="base" + pagecolor="#ffffff" + bordercolor="#666666" + borderopacity="1.0" + inkscape:pageopacity="0.0" + inkscape:pageshadow="2" + inkscape:zoom="0.7" + inkscape:cx="220.15692" + inkscape:cy="262.65754" + inkscape:document-units="px" + inkscape:current-layer="layer1" + showgrid="false" + inkscape:window-width="1280" + inkscape:window-height="888" + inkscape:window-x="-4" + inkscape:window-y="-4" + inkscape:window-maximized="1" + showguides="true" + inkscape:guide-bbox="true" /> + <metadata + id="metadata7"> + <rdf:RDF> + <cc:Work + rdf:about=""> + <dc:format>image/svg+xml</dc:format> + <dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> + <dc:title /> + </cc:Work> + </rdf:RDF> + </metadata> + <g + inkscape:label="Layer 1" + inkscape:groupmode="layer" + id="layer1" + transform="translate(-9.1421334,-233.17919)"> + <path + sodipodi:type="arc" + style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:#000000;stroke-width:10;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="path3620" + sodipodi:cx="64.649765" + sodipodi:cy="472.53461" + sodipodi:rx="117.1777" + sodipodi:ry="268.70059" + d="m 181.82746,472.53461 c 0,148.39924 -52.46224,268.70059 -117.177695,268.70059 -64.71545463,0 -117.177696,-120.30135 -117.177696,-268.70059 0,-148.39924 52.46224137,-268.7006 117.177696,-268.7006 64.715455,0 117.177695,120.30136 117.177695,268.7006 z" + transform="matrix(2.8726899,0,0,1.0798196,168.84482,21.881457)" /> + <g + id="g3694" + transform="translate(14.702487,2.8571428)"> + <path + sodipodi:nodetypes="cccc" + id="path2830" + d="m 261.68027,406.82393 36.36549,359.61431 82.97781,0 38.24049,-359.61431" + style="fill:none;stroke:#000000;stroke-width:14.10000038;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + transform="translate(-11.060917,113.98119)" + d="m 442.4468,276.6803 c 0,49.09448 -41.15572,88.89342 -91.92388,88.89342 -50.76816,0 -91.92388,-39.79894 -91.92388,-88.89342 0,-49.09449 41.15572,-88.89343 91.92388,-88.89343 50.76816,0 91.92388,39.79894 91.92388,88.89343 z" + sodipodi:ry="88.893425" + sodipodi:rx="91.923882" + sodipodi:cy="276.6803" + sodipodi:cx="350.52292" + id="path2826" + style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:#000000;stroke-width:17.61199951;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="arc" /> + <path + id="path3610" + d="M 417.09557,336.26145 265.86811,447.10263" + style="fill:none;stroke:#000000;stroke-width:8.15200043;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + id="path3610-1" + d="M 370.02409,308.17608 244.86468,399.91085" + style="fill:none;stroke:#000000;stroke-width:8.15200043;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + id="path3610-4" + d="M 266.87874,335.24091 418.10619,446.08209" + style="fill:none;stroke:#000000;stroke-width:8.15200043;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + id="path3610-4-9" + d="M 306.03234,300.77574 436.914,396.7046" + style="fill:none;stroke:#000000;stroke-width:8.15200043;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + id="path3610-4-8" + d="m 246.61065,376.5921 132.66972,97.23942" + style="fill:none;stroke:#000000;stroke-width:8.15200043;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + id="path3610-4-2" + d="M 433.44049,380.0107 304.57747,474.46002" + style="fill:none;stroke:#000000;stroke-width:8.15200043;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + </g> + </g> +</svg> diff --git a/demos/mobile/guitartuner/images/note.svg b/demos/mobile/guitartuner/images/note.svg new file mode 100644 index 0000000..c1f1771 --- /dev/null +++ b/demos/mobile/guitartuner/images/note.svg @@ -0,0 +1,101 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!-- Created with Inkscape (http://www.inkscape.org/) --> + +<svg + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:cc="http://creativecommons.org/ns#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + width="690.84283" + height="597.90881" + id="svg2" + version="1.1" + inkscape:version="0.47 r22583" + sodipodi:docname="New document 1"> + <defs + id="defs4"> + <inkscape:perspective + sodipodi:type="inkscape:persp3d" + inkscape:vp_x="0 : 526.18109 : 1" + inkscape:vp_y="0 : 1000 : 0" + inkscape:vp_z="744.09448 : 526.18109 : 1" + inkscape:persp3d-origin="372.04724 : 350.78739 : 1" + id="perspective10" /> + <inkscape:perspective + id="perspective3604" + inkscape:persp3d-origin="0.5 : 0.33333333 : 1" + inkscape:vp_z="1 : 0.5 : 1" + inkscape:vp_y="0 : 1000 : 0" + inkscape:vp_x="0 : 0.5 : 1" + sodipodi:type="inkscape:persp3d" /> + </defs> + <sodipodi:namedview + id="base" + pagecolor="#ffffff" + bordercolor="#666666" + borderopacity="1.0" + inkscape:pageopacity="0.0" + inkscape:pageshadow="2" + inkscape:zoom="0.49497475" + inkscape:cx="586.90391" + inkscape:cy="224.44944" + inkscape:document-units="px" + inkscape:current-layer="layer1" + showgrid="false" + inkscape:window-width="1280" + inkscape:window-height="888" + inkscape:window-x="-4" + inkscape:window-y="-4" + inkscape:window-maximized="1" /> + <metadata + id="metadata7"> + <rdf:RDF> + <cc:Work + rdf:about=""> + <dc:format>image/svg+xml</dc:format> + <dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> + <dc:title></dc:title> + </cc:Work> + </rdf:RDF> + </metadata> + <g + inkscape:label="Layer 1" + inkscape:groupmode="layer" + id="layer1" + transform="translate(-9.1421334,-233.17919)"> + <path + sodipodi:type="arc" + style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:#000000;stroke-width:10;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="path3620" + sodipodi:cx="64.649765" + sodipodi:cy="472.53461" + sodipodi:rx="117.1777" + sodipodi:ry="268.70059" + d="m 181.82746,472.53461 c 0,148.39924 -52.46224,268.70059 -117.177695,268.70059 -64.71545463,0 -117.177696,-120.30135 -117.177696,-268.70059 0,-148.39924 52.46224137,-268.7006 117.177696,-268.7006 64.715455,0 117.177695,120.30136 117.177695,268.7006 z" + transform="matrix(2.8726899,0,0,1.0798196,168.84482,21.881457)" /> + <path + style="fill:none;stroke:#000000;stroke-width:10;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" + d="m 355.87166,686.47203 0,-381.77521" + id="path2816" + sodipodi:nodetypes="cc" /> + <path + sodipodi:type="arc" + style="fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:5;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="path2818" + sodipodi:cx="284.86301" + sodipodi:cy="703.85956" + sodipodi:rx="80.812202" + sodipodi:ry="83.842659" + d="m 365.67521,703.85956 c 0,46.30502 -36.18086,83.84266 -80.8122,83.84266 -44.63135,0 -80.81221,-37.53764 -80.81221,-83.84266 0,-46.30502 36.18086,-83.84266 80.81221,-83.84266 44.63134,0 80.8122,37.53764 80.8122,83.84266 z" + transform="matrix(0.86662604,0,0,0.86662604,41.962127,84.107402)" /> + <path + style="fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:#000000;stroke-width:3.49788642;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + d="M 498.23775,478.96203 C 487.43102,436.20815 446.22124,431.4938 416.5823,423.48582 381.21648,411.5191 365.03425,382.76349 358.75673,339.52089 l -2.02761,-36.99987 c 12.76379,33.73415 40.64336,44.6109 67.22015,53.67478 46.38196,11.01541 67.31525,50.25786 74.72373,107.8334 0.48397,6.08567 0.99901,19.27869 0.75259,19.27869 -0.0715,0 -0.60616,-1.95564 -1.1881,-4.34586 l 0,0 2.6e-4,0 z" + id="path3618" + sodipodi:nodetypes="ccccccsccc" /> + </g> +</svg> diff --git a/demos/mobile/guitartuner/images/noteNo.svg b/demos/mobile/guitartuner/images/noteNo.svg new file mode 100644 index 0000000..888d230 --- /dev/null +++ b/demos/mobile/guitartuner/images/noteNo.svg @@ -0,0 +1,105 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!-- Created with Inkscape (http://www.inkscape.org/) --> + +<svg + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:cc="http://creativecommons.org/ns#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + width="690.84283" + height="597.90881" + id="svg2" + version="1.1" + inkscape:version="0.47 r22583" + sodipodi:docname="noteCrossed.svg"> + <defs + id="defs4"> + <inkscape:perspective + sodipodi:type="inkscape:persp3d" + inkscape:vp_x="0 : 526.18109 : 1" + inkscape:vp_y="0 : 1000 : 0" + inkscape:vp_z="744.09448 : 526.18109 : 1" + inkscape:persp3d-origin="372.04724 : 350.78739 : 1" + id="perspective10" /> + <inkscape:perspective + id="perspective3604" + inkscape:persp3d-origin="0.5 : 0.33333333 : 1" + inkscape:vp_z="1 : 0.5 : 1" + inkscape:vp_y="0 : 1000 : 0" + inkscape:vp_x="0 : 0.5 : 1" + sodipodi:type="inkscape:persp3d" /> + </defs> + <sodipodi:namedview + id="base" + pagecolor="#ffffff" + bordercolor="#666666" + borderopacity="1.0" + inkscape:pageopacity="0.0" + inkscape:pageshadow="2" + inkscape:zoom="0.49497475" + inkscape:cx="289.91906" + inkscape:cy="224.44944" + inkscape:document-units="px" + inkscape:current-layer="layer1" + showgrid="false" + inkscape:window-width="1280" + inkscape:window-height="888" + inkscape:window-x="-4" + inkscape:window-y="-4" + inkscape:window-maximized="1" /> + <metadata + id="metadata7"> + <rdf:RDF> + <cc:Work + rdf:about=""> + <dc:format>image/svg+xml</dc:format> + <dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> + <dc:title></dc:title> + </cc:Work> + </rdf:RDF> + </metadata> + <g + inkscape:label="Layer 1" + inkscape:groupmode="layer" + id="layer1" + transform="translate(-9.1421334,-233.17919)"> + <path + sodipodi:type="arc" + style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:#000000;stroke-width:10;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="path3620" + sodipodi:cx="64.649765" + sodipodi:cy="472.53461" + sodipodi:rx="117.1777" + sodipodi:ry="268.70059" + d="m 181.82746,472.53461 c 0,148.39924 -52.46224,268.70059 -117.177695,268.70059 -64.71545463,0 -117.177696,-120.30135 -117.177696,-268.70059 0,-148.39924 52.46224137,-268.7006 117.177696,-268.7006 64.715455,0 117.177695,120.30136 117.177695,268.7006 z" + transform="matrix(2.8726899,0,0,1.0798196,168.84482,21.881457)" /> + <path + style="fill:none;stroke:#000000;stroke-width:10;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" + d="m 355.87166,686.47203 0,-381.77521" + id="path2816" + sodipodi:nodetypes="cc" /> + <path + sodipodi:type="arc" + style="fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:5;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="path2818" + sodipodi:cx="284.86301" + sodipodi:cy="703.85956" + sodipodi:rx="80.812202" + sodipodi:ry="83.842659" + d="m 365.67521,703.85956 c 0,46.30502 -36.18086,83.84266 -80.8122,83.84266 -44.63135,0 -80.81221,-37.53764 -80.81221,-83.84266 0,-46.30502 36.18086,-83.84266 80.81221,-83.84266 44.63134,0 80.8122,37.53764 80.8122,83.84266 z" + transform="matrix(0.86662604,0,0,0.86662604,41.962127,84.107402)" /> + <path + style="fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:#000000;stroke-width:3.49788642;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + d="M 498.23775,478.96203 C 487.43102,436.20815 446.22124,431.4938 416.5823,423.48582 381.21648,411.5191 365.03425,382.76349 358.75673,339.52089 l -2.02761,-36.99987 c 12.76379,33.73415 40.64336,44.6109 67.22015,53.67478 46.38196,11.01541 67.31525,50.25786 74.72373,107.8334 0.48397,6.08567 0.99901,19.27869 0.75259,19.27869 -0.0715,0 -0.60616,-1.95564 -1.1881,-4.34586 l 0,0 2.6e-4,0 z" + id="path3618" + sodipodi:nodetypes="ccccccsccc" /> + <path + style="fill:none;stroke:#ff0000;stroke-width:16;stroke-linecap:round;stroke-linejoin:miter;stroke-opacity:1;stroke-miterlimit:4;stroke-dasharray:none" + d="m 176.92972,346.31704 369.5113,373.55192" + id="path2817" /> + </g> +</svg> diff --git a/demos/mobile/guitartuner/src/application.qml b/demos/mobile/guitartuner/src/application.qml new file mode 100644 index 0000000..7da138d --- /dev/null +++ b/demos/mobile/guitartuner/src/application.qml @@ -0,0 +1,328 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 1.0 +import "mycomponents" + +/* The base canvas for all QML drawing. */ +Rectangle { + id: application + + property int targetNoteIndex: 0 + property alias frequency: noteChooser.currentFrequency + //Data provided to C++. + property bool isInput: true + property bool isMuted: false + property bool isAuto: true + property alias maxVoiceDifference: voiceDifferenceMeter.maxValue + property real volume: 0.5 + property real sensitivity: 0.5 + + //Signals to C++. + signal volumeChanged(real volume) + signal microphoneSensitivityChanged(real sensitivity) + signal targetFrequencyChanged(real frequency) + signal modeChanged(bool isInput) + signal muteStateChanged(bool isMuted) + + //Slots for signals coming from C++. + function voiceDifferenceChanged(difference) { + if (isAuto) timer.running = true; + voiceDifferenceMeter.valueChanged(difference); + noteImage.glowing = false + } + function correctFrequencyObtained() { + noteImage.glowing = true + } + function lowVoice() { + noteImage.glowing = false + } + + //Private function for changing the target frequency automatically. + function calculateTargetFrequency(difference) { + var tempDifference = Math.abs(difference); + var tempIndex = targetNoteIndex + while (!(difference < 0 && tempIndex == 0) && + tempDifference >= notes.get(tempIndex-(difference<0)).interval/2) { + tempDifference -= notes.get(tempIndex-(difference<0)).interval; + tempIndex += difference/Math.abs(difference); + } + if (tempIndex != targetNoteIndex) { + targetNoteIndex = tempIndex + noteChooser.currentFrequency = notes.get(targetNoteIndex).frequency; + targetFrequencyChanged(frequency); + } + } + + width: 360; height: 640 + color: "black" + + //Provides data for functions. + NotesModel {id: notes} + + /* A timer for changing the target frequency automatically. + * This is needed for avoiding recursion. */ + Timer { + id: timer + + interval: 1 + onTriggered: calculateTargetFrequency(voiceDifferenceMeter.value) + } + + //A meter for showing the difference between current and target frequency. + Meter { + id: voiceDifferenceMeter + + maxValue: 12 + minValue: -maxValue + height: imageSize.height/background.sourceSize.height*parent.height + width: imageSize.width/background.sourceSize.width*parent.width + anchors { + topMargin: 100/background.sourceSize.height*parent.height + horizontalCenter: parent.horizontalCenter + top: parent.top + } + } + + Image { + id: background + + anchors.fill: parent + smooth: true + source: "./mycomponents/images/guitartuner_skin.png" + } + + //A button for quitting the application. + Image { + id: quitButton + + width: sourceSize.width/background.sourceSize.width*parent.width + height: sourceSize.height/background.sourceSize.height*parent.height + source: "./mycomponents/images/power.png" + smooth: true + KeyNavigation.up: volumeAdjuster + KeyNavigation.down: modeButton + Keys.onEnterPressed: Qt.quit() + anchors{ + leftMargin: 297/background.sourceSize.width*parent.width + left: parent.left; + topMargin: 17/background.sourceSize.height*parent.height + top: parent.top + } + + MouseArea { + anchors.fill: parent + onClicked: Qt.quit() + } + } + + //An image for showing the target note. + Image { + id: noteImage + + property bool glowing: false + + width: sourceSize.width/background.sourceSize.width*parent.width + height: sourceSize.height/background.sourceSize.height*parent.height + source: glowing ? notes.get(targetNoteIndex).glowSource : notes.get(targetNoteIndex).bigSource + + anchors { + topMargin: 273/background.sourceSize.height*parent.height + top: parent.top + horizontalCenter: parent.horizontalCenter + } + } + + //A button for choosing the input/output mode. + Image { + id: modeButton + + function buttonPressed() { + isInput = !isInput + modeChanged(isInput) + if (isInput) { + soundIcons.source = "./mycomponents/images/sensitivity.png" + source = "./mycomponents/images/voicemode_off.png" + volumeAdjuster.setValue(sensitivity) + } + else { + //Change off from "auto" mode + if (isAuto) { + noteChooser.pushButton(targetNoteIndex) + } + if (isMuted) { + soundIcons.source = "./mycomponents/images/volume_off.png"; + } + else + soundIcons.source = "./mycomponents/images/volume.png" + source = "./mycomponents/images/voicemode_on.png" + volumeAdjuster.setValue(volume) + } + } + + width: sourceSize.width/background.sourceSize.width*parent.width + height: sourceSize.height/background.sourceSize.height*parent.height + smooth: true + source: "./mycomponents/images/voicemode_off.png" + KeyNavigation.up: quitButton + KeyNavigation.down: noteChooser + Keys.onEnterPressed: buttonPressed() + anchors { + leftMargin: 16/background.sourceSize.width*parent.width + left: parent.left + topMargin: 353/background.sourceSize.height*parent.height + top: parent.top + } + + MouseArea { + anchors.fill: parent + onPressed: { + parent.focus = true + parent.scale = 0.95 + } + onReleased: { + parent.scale = 1/0.95 + } + onClicked: parent.buttonPressed() + } + } + + //Buttons for choosing the target note. + NoteButtonView { + id: noteChooser + + width: parent.width*0.95; height: width/model.count + onNoteSelected: { + if (note == "Auto") { + if (!isAuto) { + isAuto = true + } + if (!isInput) { + modeButton.buttonPressed() + } + } + else { + timer.running = false; + isAuto = false + targetNoteIndex = index + targetFrequencyChanged(frequency) + } + focus = true + } + KeyNavigation.up: modeButton + KeyNavigation.down: soundIcons + anchors { + horizontalCenter: parent.horizontalCenter + topMargin: 454/background.sourceSize.height*parent.height + top: parent.top + } + } + + //An element for showing the mode and changing the mute state. + Image { + id: soundIcons + + function stateChanged() { + isMuted = !isMuted + muteStateChanged(isMuted) + if (isMuted) { + source = "qrc:/src/mycomponents/images/volume_off.png" + } + else { + source = "qrc:/src/mycomponents/images/volume.png" + } + } + + width: sourceSize.width/background.sourceSize.width*parent.width + height: sourceSize.height/background.sourceSize.height*parent.height + smooth: true + source: "./mycomponents/images/sensitivity.png" + Keys.onEnterPressed: stateChanged() + KeyNavigation.up: noteChooser + KeyNavigation.down: quitButton + KeyNavigation.left: volumeAdjuster + KeyNavigation.right: volumeAdjuster + anchors { + leftMargin: 42/background.sourceSize.width*parent.width + left: parent.left + topMargin: 565/background.sourceSize.height*parent.height + top: parent.top + } + + MouseArea { + anchors.fill: parent + onClicked: { + if (!isInput) { + parent.stateChanged() + } + parent.focus = true + } + } + } + + //An element for adjusting volume. + Adjuster { + id: volumeAdjuster + + max: 1 + value: 0.5 + width: 222/background.sourceSize.width*parent.width + height: parent.height*0.1 + onFocusChangedByClick: focus = true + onArrowPressedWhenValueOverLimits: soundIcons.focus = true + KeyNavigation.up: modeButton + KeyNavigation.down: quitButton + anchors { + leftMargin: 98/background.sourceSize.width*parent.width + left: parent.left + verticalCenter: soundIcons.verticalCenter + } + onValueChanged: { + if (isInput) { + sensitivity = value; + microphoneSensitivityChanged(1-sensitivity) + } + else { + volume = value + volumeChanged(volume) + } + } + } +} diff --git a/demos/mobile/guitartuner/src/constants.h b/demos/mobile/guitartuner/src/constants.h new file mode 100644 index 0000000..c3eddaa --- /dev/null +++ b/demos/mobile/guitartuner/src/constants.h @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef CONSTANTS_H +#define CONSTANTS_H + +#define M_MAX_AMPLITUDE_8BIT_SIGNED 127 +#define M_MAX_AMPLITUDE_8BIT_UNSIGNED 255 +#define M_MAX_AMPLITUDE_16BIT_SIGNED 32767 +#define M_MAX_AMPLITUDE_16BIT_UNSIGNED 65535 + +#define M_TWELTH_ROOT_OF_2 1.05946309435930000000 + +// M_SAMPLE_COUNT_MULTIPLIER is 2/(M_TWELTH_ROOT_OF_2 - 1) +#define M_SAMPLE_COUNT_MULTIPLIER 33.63430749021150000000 + +#endif // CONSTANTS_H diff --git a/demos/mobile/guitartuner/src/fastfouriertransformer.cpp b/demos/mobile/guitartuner/src/fastfouriertransformer.cpp new file mode 100644 index 0000000..9158fd4 --- /dev/null +++ b/demos/mobile/guitartuner/src/fastfouriertransformer.cpp @@ -0,0 +1,184 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "fastfouriertransformer.h" +#include "math.h" + +#define STIN inline +#define __STATIC + +#include "fftpack.c" + +// called by __ogg_fdrffti +__STATIC void drfti1(int n, float *wa, int *ifac); +void __ogg_fdrffti(int n, float *wsave, int *ifac); +void __ogg_fdcosqi(int n, float *wsave, int *ifac); +// called by drftf1 +STIN void dradf2(int ido,int l1,float *cc,float *ch,float *wa1); +// called by drftf1 +STIN void dradf4(int ido,int l1,float *cc,float *ch,float *wa1, + float *wa2,float *wa3); +// called by drftf1 +STIN void dradfg(int ido,int ip,int l1,int idl1,float *cc,float *c1, + float *c2,float *ch,float *ch2,float *wa); +// called by drftf1 +STIN void drftf1(int n,float *c,float *ch,float *wa,int *ifac); +void __ogg_fdrfftf(int n,float *r,float *wsave,int *ifac); +STIN void dcsqf1(int n,float *x,float *w,float *xh,int *ifac); +void __ogg_fdcosqf(int n,float *x,float *wsave,int *ifac); +STIN void dradb2(int ido,int l1,float *cc,float *ch,float *wa1); +STIN void dradb3(int ido,int l1,float *cc,float *ch,float *wa1, + float *wa2); +STIN void dradb4(int ido,int l1,float *cc,float *ch,float *wa1, + float *wa2,float *wa3); +STIN void dradbg(int ido,int ip,int l1,int idl1,float *cc,float *c1, + float *c2,float *ch,float *ch2,float *wa); +STIN void drftb1(int n, float *c, float *ch, float *wa, int *ifac); +void __ogg_fdrfftb(int n, float *r, float *wsave, int *ifac); +STIN void dcsqb1(int n,float *x,float *w,float *xh,int *ifac); +void __ogg_fdcosqb(int n,float *x,float *wsave,int *ifac); + +FastFourierTransformer::FastFourierTransformer(QObject *parent) : + QObject(parent), + m_waveFloat(0), + m_workingArray(0), + m_ifac(0), + m_last_n(-1) +{ +} + +FastFourierTransformer::~FastFourierTransformer() +{ + if (m_waveFloat != 0) { + delete [] m_waveFloat; + } + if (m_workingArray != 0) { + delete [] m_workingArray; + } + if (m_ifac != 0) { + delete [] m_ifac; + } +} + +/** + * Prepares the arrays to be of length n. + */ +void FastFourierTransformer::reserve(int n) +{ + Q_ASSERT(n>0); + if (m_waveFloat != 0) { + delete [] m_waveFloat; + } + if (m_workingArray != 0) { + delete [] m_workingArray; + } + if (m_ifac != 0) { + delete [] m_ifac; + } + m_workingArray = new float[2*n+15]; + m_waveFloat = new float[n]; + m_ifac = new int[n]; + __ogg_fdrffti(n, m_workingArray, m_ifac); + m_last_n = n; +} + +/** + * Calculates the Fast Fourier Transformation (FFT). + */ +void FastFourierTransformer::calculateFFT(QList<qint16> wave) +{ + const int n = wave.size(); + if (m_last_n != n) { + reserve(n); + } + for (int i = 0; i < n; i++) { + m_waveFloat[i] = (float) wave.at(i); + } + + __ogg_fdrfftf(n, m_waveFloat, m_workingArray, m_ifac); + +} + +/** + * Returns the index which corresponds to the maximum density + * of the FFT. + */ +int FastFourierTransformer::getMaximumDensityIndex() +{ + const int halfN = m_last_n / 2; + float maxDensity = 0; + int maxDensityIndex = 0; + float densitySquared = 0.f; + for (int k = 1; k < halfN; k++) { + // Here, we calculate the frequency k/N. + // k=1, the wave oscillation time is N, and the frequency + // is 1/sample. + // k=2, the wave oscillation time is N/2, and the frequency + // is 2/sample. + // k=3, the wave oscillation time is N/3, and the frequency + // is 3/sample. + // Note, that the documentation is for Fortran, so indexes in the + // documentation does not match. + // The sine and cosine coefficients are obtained thus as follows: + const float cosCoefficient = qAbs(m_waveFloat[2*k-1]); + const float sinCoefficient = qAbs(m_waveFloat[2*k]); + + densitySquared = sinCoefficient*sinCoefficient + cosCoefficient*cosCoefficient; + if (densitySquared > maxDensity) { + maxDensity = densitySquared; + maxDensityIndex = k; + } + } + + if (m_cutOffForDensitySquared < maxDensity) { + return maxDensityIndex; + } + else { + return -1; + } +} + +/** + * Sets the cutoff density. + */ +void FastFourierTransformer::setCutOffForDensity(float cutoff) +{ + m_cutOffForDensitySquared = cutoff*cutoff; +} diff --git a/demos/mobile/guitartuner/src/fastfouriertransformer.h b/demos/mobile/guitartuner/src/fastfouriertransformer.h new file mode 100644 index 0000000..d126b45 --- /dev/null +++ b/demos/mobile/guitartuner/src/fastfouriertransformer.h @@ -0,0 +1,67 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef FASTFOURIERTRANSFORM_H +#define FASTFOURIERTRANSFORM_H + +#include <QObject> +#include <QList> + +class FastFourierTransformer : public QObject +{ + Q_OBJECT + +public: + FastFourierTransformer(QObject *parent = 0); + ~FastFourierTransformer(); + void reserve(int n); + void calculateFFT(QList<qint16> wave); + int getMaximumDensityIndex(); + void setCutOffForDensity(float cutoff); + +private: + float *m_waveFloat; + float *m_workingArray; + int *m_ifac; + int m_last_n; + float m_cutOffForDensitySquared; +}; + +#endif // FASTFOURIERTRANSFORM_H diff --git a/demos/mobile/guitartuner/src/fftpack.c b/demos/mobile/guitartuner/src/fftpack.c new file mode 100644 index 0000000..24eaa57 --- /dev/null +++ b/demos/mobile/guitartuner/src/fftpack.c @@ -0,0 +1,1406 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/******************************************************************** + + The routines in this file are from http://www.netlib.org/fftpack/. + According to the comments in the original file (which are provided below) + and according to the wikipedia article about the FFTPACK[1], + they are released as public domain. + + For information about the author of the original, Fortran routines, + and the author of the C translation these routines, + see the comments below. + + [1] http://en.wikipedia.org/wiki/FFTPACK, referenced 2010-12-21. + + ********************************************************************/ + +/******************************************************************** + + file: fft.c + function: Fast discrete Fourier and cosine transforms and inverses + author: Monty <xiphmont@mit.edu> + modifications by: Monty + last modification date: Jul 1 1996 + + ********************************************************************/ + +/* These Fourier routines were originally based on the Fourier + routines of the same names from the NETLIB bihar and fftpack + fortran libraries developed by Paul N. Swarztrauber at the National + Center for Atmospheric Research in Boulder, CO USA. They have been + reimplemented in C and optimized in a few ways for OggSquish. */ + +/* As the original fortran libraries are public domain, the C Fourier + routines in this file are hereby released to the public domain as + well. The C routines here produce output exactly equivalent to the + original fortran routines. Of particular interest are the facts + that (like the original fortran), these routines can work on + arbitrary length vectors that need not be powers of two in + length. */ + +#include <math.h> + +__STATIC void drfti1(int n, float *wa, int *ifac){ + static int ntryh[4] = { 4,2,3,5 }; + static float tpi = 6.28318530717958647692528676655900577; + float arg,argh,argld,fi; + int ntry=0,i,j=-1; + int k1, l1, l2, ib; + int ld, ii, ip, is, nq, nr; + int ido, ipm, nfm1; + int nl=n; + int nf=0; + + L101: + j++; + if (j < 4) + ntry=ntryh[j]; + else + ntry+=2; + + L104: + nq=nl/ntry; + nr=nl-ntry*nq; + if (nr!=0) goto L101; + + nf++; + ifac[nf+1]=ntry; + nl=nq; + if (ntry!=2) goto L107; + if (nf==1) goto L107; + + for (i=1;i<nf;i++){ + ib=nf-i+1; + ifac[ib+1]=ifac[ib]; + } + ifac[2] = 2; + + L107: + if (nl!=1) goto L104; + ifac[0]=n; + ifac[1]=nf; + argh=tpi/n; + is=0; + nfm1=nf-1; + l1=1; + + if (nfm1==0) return; + + for (k1=0;k1<nfm1;k1++){ + ip=ifac[k1+2]; + ld=0; + l2=l1*ip; + ido=n/l2; + ipm=ip-1; + + for (j=0;j<ipm;j++){ + ld+=l1; + i=is; + argld=(float)ld*argh; + fi=0.; + for (ii=2;ii<ido;ii+=2){ + fi+=1.; + arg=fi*argld; + wa[i++]=cos(arg); + wa[i++]=sin(arg); + } + is+=ido; + } + l1=l2; + } +} + +void __ogg_fdrffti(int n, float *wsave, int *ifac){ + + if (n == 1) return; + drfti1(n, wsave+n, ifac); +} + +void __ogg_fdcosqi(int n, float *wsave, int *ifac){ + static float pih = 1.57079632679489661923132169163975; + static int k; + static float fk, dt; + + dt=pih/n; + fk=0.; + for (k=0;k<n;k++){ + fk+=1.; + wsave[k] = cos(fk*dt); + } + + __ogg_fdrffti(n, wsave+n,ifac); +} + +STIN void dradf2(int ido,int l1,float *cc,float *ch,float *wa1){ + int i,k; + float ti2,tr2; + int t0,t1,t2,t3,t4,t5,t6; + + t1=0; + t0=(t2=l1*ido); + t3=ido<<1; + for (k=0;k<l1;k++){ + ch[t1<<1]=cc[t1]+cc[t2]; + ch[(t1<<1)+t3-1]=cc[t1]-cc[t2]; + t1+=ido; + t2+=ido; + } + + if (ido<2) return; + if (ido==2) goto L105; + + t1=0; + t2=t0; + for (k=0;k<l1;k++){ + t3=t2; + t4=(t1<<1)+(ido<<1); + t5=t1; + t6=t1+t1; + for (i=2;i<ido;i+=2){ + t3+=2; + t4-=2; + t5+=2; + t6+=2; + tr2=wa1[i-2]*cc[t3-1]+wa1[i-1]*cc[t3]; + ti2=wa1[i-2]*cc[t3]-wa1[i-1]*cc[t3-1]; + ch[t6]=cc[t5]+ti2; + ch[t4]=ti2-cc[t5]; + ch[t6-1]=cc[t5-1]+tr2; + ch[t4-1]=cc[t5-1]-tr2; + } + t1+=ido; + t2+=ido; + } + + if (ido%2==1) return; + + L105: + t3=(t2=(t1=ido)-1); + t2+=t0; + for (k=0;k<l1;k++){ + ch[t1]=-cc[t2]; + ch[t1-1]=cc[t3]; + t1+=ido<<1; + t2+=ido; + t3+=ido; + } +} + +STIN void dradf4(int ido,int l1,float *cc,float *ch,float *wa1, + float *wa2,float *wa3){ + static float hsqt2 = .70710678118654752440084436210485; + int i,k,t0,t1,t2,t3,t4,t5,t6; + float ci2,ci3,ci4,cr2,cr3,cr4,ti1,ti2,ti3,ti4,tr1,tr2,tr3,tr4; + t0=l1*ido; + + t1=t0; + t4=t1<<1; + t2=t1+(t1<<1); + t3=0; + + for (k=0;k<l1;k++){ + tr1=cc[t1]+cc[t2]; + tr2=cc[t3]+cc[t4]; + ch[t5=t3<<2]=tr1+tr2; + ch[(ido<<2)+t5-1]=tr2-tr1; + ch[(t5+=(ido<<1))-1]=cc[t3]-cc[t4]; + ch[t5]=cc[t2]-cc[t1]; + + t1+=ido; + t2+=ido; + t3+=ido; + t4+=ido; + } + + if (ido<2) return; + if (ido==2) goto L105; + + t1=0; + for (k=0;k<l1;k++){ + t2=t1; + t4=t1<<2; + t5=(t6=ido<<1)+t4; + for (i=2;i<ido;i+=2){ + t3=(t2+=2); + t4+=2; + t5-=2; + + t3+=t0; + cr2=wa1[i-2]*cc[t3-1]+wa1[i-1]*cc[t3]; + ci2=wa1[i-2]*cc[t3]-wa1[i-1]*cc[t3-1]; + t3+=t0; + cr3=wa2[i-2]*cc[t3-1]+wa2[i-1]*cc[t3]; + ci3=wa2[i-2]*cc[t3]-wa2[i-1]*cc[t3-1]; + t3+=t0; + cr4=wa3[i-2]*cc[t3-1]+wa3[i-1]*cc[t3]; + ci4=wa3[i-2]*cc[t3]-wa3[i-1]*cc[t3-1]; + + tr1=cr2+cr4; + tr4=cr4-cr2; + ti1=ci2+ci4; + ti4=ci2-ci4; + ti2=cc[t2]+ci3; + ti3=cc[t2]-ci3; + tr2=cc[t2-1]+cr3; + tr3=cc[t2-1]-cr3; + + + ch[t4-1]=tr1+tr2; + ch[t4]=ti1+ti2; + + ch[t5-1]=tr3-ti4; + ch[t5]=tr4-ti3; + + ch[t4+t6-1]=ti4+tr3; + ch[t4+t6]=tr4+ti3; + + ch[t5+t6-1]=tr2-tr1; + ch[t5+t6]=ti1-ti2; + } + t1+=ido; + } + if (ido%2==1) return; + + L105: + + t2=(t1=t0+ido-1)+(t0<<1); + t3=ido<<2; + t4=ido; + t5=ido<<1; + t6=ido; + + for (k=0;k<l1;k++){ + ti1=-hsqt2*(cc[t1]+cc[t2]); + tr1=hsqt2*(cc[t1]-cc[t2]); + ch[t4-1]=tr1+cc[t6-1]; + ch[t4+t5-1]=cc[t6-1]-tr1; + ch[t4]=ti1-cc[t1+t0]; + ch[t4+t5]=ti1+cc[t1+t0]; + t1+=ido; + t2+=ido; + t4+=t3; + t6+=ido; + } +} + +STIN void dradfg(int ido,int ip,int l1,int idl1,float *cc,float *c1, + float *c2,float *ch,float *ch2,float *wa){ + + static float tpi=6.28318530717958647692528676655900577; + int idij,ipph,i,j,k,l,ic,ik,is; + int t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10; + float dc2,ai1,ai2,ar1,ar2,ds2; + int nbd; + float dcp,arg,dsp,ar1h,ar2h; + int idp2,ipp2; + + arg=tpi/(float)ip; + dcp=cos(arg); + dsp=sin(arg); + ipph=(ip+1)>>1; + ipp2=ip; + idp2=ido; + nbd=(ido-1)>>1; + t0=l1*ido; + t10=ip*ido; + + if (ido==1) goto L119; + for (ik=0;ik<idl1;ik++)ch2[ik]=c2[ik]; + + t1=0; + for (j=1;j<ip;j++){ + t1+=t0; + t2=t1; + for (k=0;k<l1;k++){ + ch[t2]=c1[t2]; + t2+=ido; + } + } + + is=-ido; + t1=0; + if (nbd>l1){ + for (j=1;j<ip;j++){ + t1+=t0; + is+=ido; + t2= -ido+t1; + for (k=0;k<l1;k++){ + idij=is-1; + t2+=ido; + t3=t2; + for (i=2;i<ido;i+=2){ + idij+=2; + t3+=2; + ch[t3-1]=wa[idij-1]*c1[t3-1]+wa[idij]*c1[t3]; + ch[t3]=wa[idij-1]*c1[t3]-wa[idij]*c1[t3-1]; + } + } + } + }else{ + + for (j=1;j<ip;j++){ + is+=ido; + idij=is-1; + t1+=t0; + t2=t1; + for (i=2;i<ido;i+=2){ + idij+=2; + t2+=2; + t3=t2; + for (k=0;k<l1;k++){ + ch[t3-1]=wa[idij-1]*c1[t3-1]+wa[idij]*c1[t3]; + ch[t3]=wa[idij-1]*c1[t3]-wa[idij]*c1[t3-1]; + t3+=ido; + } + } + } + } + + t1=0; + t2=ipp2*t0; + if (nbd<l1){ + for (j=1;j<ipph;j++){ + t1+=t0; + t2-=t0; + t3=t1; + t4=t2; + for (i=2;i<ido;i+=2){ + t3+=2; + t4+=2; + t5=t3-ido; + t6=t4-ido; + for (k=0;k<l1;k++){ + t5+=ido; + t6+=ido; + c1[t5-1]=ch[t5-1]+ch[t6-1]; + c1[t6-1]=ch[t5]-ch[t6]; + c1[t5]=ch[t5]+ch[t6]; + c1[t6]=ch[t6-1]-ch[t5-1]; + } + } + } + }else{ + for (j=1;j<ipph;j++){ + t1+=t0; + t2-=t0; + t3=t1; + t4=t2; + for (k=0;k<l1;k++){ + t5=t3; + t6=t4; + for (i=2;i<ido;i+=2){ + t5+=2; + t6+=2; + c1[t5-1]=ch[t5-1]+ch[t6-1]; + c1[t6-1]=ch[t5]-ch[t6]; + c1[t5]=ch[t5]+ch[t6]; + c1[t6]=ch[t6-1]-ch[t5-1]; + } + t3+=ido; + t4+=ido; + } + } + } + +L119: + for (ik=0;ik<idl1;ik++)c2[ik]=ch2[ik]; + + t1=0; + t2=ipp2*idl1; + for (j=1;j<ipph;j++){ + t1+=t0; + t2-=t0; + t3=t1-ido; + t4=t2-ido; + for (k=0;k<l1;k++){ + t3+=ido; + t4+=ido; + c1[t3]=ch[t3]+ch[t4]; + c1[t4]=ch[t4]-ch[t3]; + } + } + + ar1=1.; + ai1=0.; + t1=0; + t2=ipp2*idl1; + t3=(ip-1)*idl1; + for (l=1;l<ipph;l++){ + t1+=idl1; + t2-=idl1; + ar1h=dcp*ar1-dsp*ai1; + ai1=dcp*ai1+dsp*ar1; + ar1=ar1h; + t4=t1; + t5=t2; + t6=t3; + t7=idl1; + + for (ik=0;ik<idl1;ik++){ + ch2[t4++]=c2[ik]+ar1*c2[t7++]; + ch2[t5++]=ai1*c2[t6++]; + } + + dc2=ar1; + ds2=ai1; + ar2=ar1; + ai2=ai1; + + t4=idl1; + t5=(ipp2-1)*idl1; + for (j=2;j<ipph;j++){ + t4+=idl1; + t5-=idl1; + + ar2h=dc2*ar2-ds2*ai2; + ai2=dc2*ai2+ds2*ar2; + ar2=ar2h; + + t6=t1; + t7=t2; + t8=t4; + t9=t5; + for (ik=0;ik<idl1;ik++){ + ch2[t6++]+=ar2*c2[t8++]; + ch2[t7++]+=ai2*c2[t9++]; + } + } + } + + t1=0; + for (j=1;j<ipph;j++){ + t1+=idl1; + t2=t1; + for (ik=0;ik<idl1;ik++)ch2[ik]+=c2[t2++]; + } + + if (ido<l1) goto L132; + + t1=0; + t2=0; + for (k=0;k<l1;k++){ + t3=t1; + t4=t2; + for (i=0;i<ido;i++)cc[t4++]=ch[t3++]; + t1+=ido; + t2+=t10; + } + + goto L135; + + L132: + for (i=0;i<ido;i++){ + t1=i; + t2=i; + for (k=0;k<l1;k++){ + cc[t2]=ch[t1]; + t1+=ido; + t2+=t10; + } + } + + L135: + t1=0; + t2=ido<<1; + t3=0; + t4=ipp2*t0; + for (j=1;j<ipph;j++){ + + t1+=t2; + t3+=t0; + t4-=t0; + + t5=t1; + t6=t3; + t7=t4; + + for (k=0;k<l1;k++){ + cc[t5-1]=ch[t6]; + cc[t5]=ch[t7]; + t5+=t10; + t6+=ido; + t7+=ido; + } + } + + if (ido==1) return; + if (nbd<l1) goto L141; + + t1=-ido; + t3=0; + t4=0; + t5=ipp2*t0; + for (j=1;j<ipph;j++){ + t1+=t2; + t3+=t2; + t4+=t0; + t5-=t0; + t6=t1; + t7=t3; + t8=t4; + t9=t5; + for (k=0;k<l1;k++){ + for (i=2;i<ido;i+=2){ + ic=idp2-i; + cc[i+t7-1]=ch[i+t8-1]+ch[i+t9-1]; + cc[ic+t6-1]=ch[i+t8-1]-ch[i+t9-1]; + cc[i+t7]=ch[i+t8]+ch[i+t9]; + cc[ic+t6]=ch[i+t9]-ch[i+t8]; + } + t6+=t10; + t7+=t10; + t8+=ido; + t9+=ido; + } + } + return; + + L141: + + t1=-ido; + t3=0; + t4=0; + t5=ipp2*t0; + for (j=1;j<ipph;j++){ + t1+=t2; + t3+=t2; + t4+=t0; + t5-=t0; + for (i=2;i<ido;i+=2){ + t6=idp2+t1-i; + t7=i+t3; + t8=i+t4; + t9=i+t5; + for (k=0;k<l1;k++){ + cc[t7-1]=ch[t8-1]+ch[t9-1]; + cc[t6-1]=ch[t8-1]-ch[t9-1]; + cc[t7]=ch[t8]+ch[t9]; + cc[t6]=ch[t9]-ch[t8]; + t6+=t10; + t7+=t10; + t8+=ido; + t9+=ido; + } + } + } +} + +STIN void drftf1(int n,float *c,float *ch,float *wa,int *ifac){ + int i,k1,l1,l2; + int na,kh,nf; + int ip,iw,ido,idl1,ix2,ix3; + + nf=ifac[1]; + na=1; + l2=n; + iw=n; + + for (k1=0;k1<nf;k1++){ + kh=nf-k1; + ip=ifac[kh+1]; + l1=l2/ip; + ido=n/l2; + idl1=ido*l1; + iw-=(ip-1)*ido; + na=1-na; + + if (ip!=4) goto L102; + + ix2=iw+ido; + ix3=ix2+ido; + if (na!=0) + dradf4(ido,l1,ch,c,wa+iw-1,wa+ix2-1,wa+ix3-1); + else + dradf4(ido,l1,c,ch,wa+iw-1,wa+ix2-1,wa+ix3-1); + goto L110; + + L102: + if (ip!=2) goto L104; + if (na!=0) goto L103; + + dradf2(ido,l1,c,ch,wa+iw-1); + goto L110; + + L103: + dradf2(ido,l1,ch,c,wa+iw-1); + goto L110; + + L104: + if (ido==1)na=1-na; + if (na!=0) goto L109; + + dradfg(ido,ip,l1,idl1,c,c,c,ch,ch,wa+iw-1); + na=1; + goto L110; + + L109: + dradfg(ido,ip,l1,idl1,ch,ch,ch,c,c,wa+iw-1); + na=0; + + L110: + l2=l1; + } + + if (na==1) return; + + for (i=0;i<n;i++)c[i]=ch[i]; +} + +void __ogg_fdrfftf(int n,float *r,float *wsave,int *ifac){ + if (n==1) return; + drftf1(n,r,wsave,wsave+n,ifac); +} + +STIN void dcsqf1(int n,float *x,float *w,float *xh,int *ifac){ + int modn,i,k,kc; + int np2,ns2; + float xim1; + + ns2=(n+1)>>1; + np2=n; + + kc=np2; + for (k=1;k<ns2;k++){ + kc--; + xh[k]=x[k]+x[kc]; + xh[kc]=x[k]-x[kc]; + } + + modn=n%2; + if (modn==0)xh[ns2]=x[ns2]+x[ns2]; + + for (k=1;k<ns2;k++){ + kc=np2-k; + x[k]=w[k-1]*xh[kc]+w[kc-1]*xh[k]; + x[kc]=w[k-1]*xh[k]-w[kc-1]*xh[kc]; + } + + if (modn==0)x[ns2]=w[ns2-1]*xh[ns2]; + + __ogg_fdrfftf(n,x,xh,ifac); + + for (i=2;i<n;i+=2){ + xim1=x[i-1]-x[i]; + x[i]=x[i-1]+x[i]; + x[i-1]=xim1; + } +} + +void __ogg_fdcosqf(int n,float *x,float *wsave,int *ifac){ + static float sqrt2=1.4142135623730950488016887242097; + float tsqx; + + switch (n){ + case 0:case 1: + return; + case 2: + tsqx=sqrt2*x[1]; + x[1]=x[0]-tsqx; + x[0]+=tsqx; + return; + default: + dcsqf1(n,x,wsave,wsave+n,ifac); + return; + } +} + +STIN void dradb2(int ido,int l1,float *cc,float *ch,float *wa1){ + int i,k,t0,t1,t2,t3,t4,t5,t6; + float ti2,tr2; + + t0=l1*ido; + + t1=0; + t2=0; + t3=(ido<<1)-1; + for (k=0;k<l1;k++){ + ch[t1]=cc[t2]+cc[t3+t2]; + ch[t1+t0]=cc[t2]-cc[t3+t2]; + t2=(t1+=ido)<<1; + } + + if (ido<2) return; + if (ido==2) goto L105; + + t1=0; + t2=0; + for (k=0;k<l1;k++){ + t3=t1; + t5=(t4=t2)+(ido<<1); + t6=t0+t1; + for (i=2;i<ido;i+=2){ + t3+=2; + t4+=2; + t5-=2; + t6+=2; + ch[t3-1]=cc[t4-1]+cc[t5-1]; + tr2=cc[t4-1]-cc[t5-1]; + ch[t3]=cc[t4]-cc[t5]; + ti2=cc[t4]+cc[t5]; + ch[t6-1]=wa1[i-2]*tr2-wa1[i-1]*ti2; + ch[t6]=wa1[i-2]*ti2+wa1[i-1]*tr2; + } + t2=(t1+=ido)<<1; + } + + if (ido%2==1) return; + +L105: + t1=ido-1; + t2=ido-1; + for (k=0;k<l1;k++){ + ch[t1]=cc[t2]+cc[t2]; + ch[t1+t0]=-(cc[t2+1]+cc[t2+1]); + t1+=ido; + t2+=ido<<1; + } +} + +STIN void dradb3(int ido,int l1,float *cc,float *ch,float *wa1, + float *wa2){ + static float taur = -.5; + static float taui = .86602540378443864676372317075293618; + int i,k,t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10; + float ci2,ci3,di2,di3,cr2,cr3,dr2,dr3,ti2,tr2; + t0=l1*ido; + + t1=0; + t2=t0<<1; + t3=ido<<1; + t4=ido+(ido<<1); + t5=0; + for (k=0;k<l1;k++){ + tr2=cc[t3-1]+cc[t3-1]; + cr2=cc[t5]+(taur*tr2); + ch[t1]=cc[t5]+tr2; + ci3=taui*(cc[t3]+cc[t3]); + ch[t1+t0]=cr2-ci3; + ch[t1+t2]=cr2+ci3; + t1+=ido; + t3+=t4; + t5+=t4; + } + + if (ido==1) return; + + t1=0; + t3=ido<<1; + for (k=0;k<l1;k++){ + t7=t1+(t1<<1); + t6=(t5=t7+t3); + t8=t1; + t10=(t9=t1+t0)+t0; + + for (i=2;i<ido;i+=2){ + t5+=2; + t6-=2; + t7+=2; + t8+=2; + t9+=2; + t10+=2; + tr2=cc[t5-1]+cc[t6-1]; + cr2=cc[t7-1]+(taur*tr2); + ch[t8-1]=cc[t7-1]+tr2; + ti2=cc[t5]-cc[t6]; + ci2=cc[t7]+(taur*ti2); + ch[t8]=cc[t7]+ti2; + cr3=taui*(cc[t5-1]-cc[t6-1]); + ci3=taui*(cc[t5]+cc[t6]); + dr2=cr2-ci3; + dr3=cr2+ci3; + di2=ci2+cr3; + di3=ci2-cr3; + ch[t9-1]=wa1[i-2]*dr2-wa1[i-1]*di2; + ch[t9]=wa1[i-2]*di2+wa1[i-1]*dr2; + ch[t10-1]=wa2[i-2]*dr3-wa2[i-1]*di3; + ch[t10]=wa2[i-2]*di3+wa2[i-1]*dr3; + } + t1+=ido; + } +} + +STIN void dradb4(int ido,int l1,float *cc,float *ch,float *wa1, + float *wa2,float *wa3){ + static float sqrt2=1.4142135623730950488016887242097; + int i,k,t0,t1,t2,t3,t4,t5,t6,t7,t8; + float ci2,ci3,ci4,cr2,cr3,cr4,ti1,ti2,ti3,ti4,tr1,tr2,tr3,tr4; + t0=l1*ido; + + t1=0; + t2=ido<<2; + t3=0; + t6=ido<<1; + for (k=0;k<l1;k++){ + t4=t3+t6; + t5=t1; + tr3=cc[t4-1]+cc[t4-1]; + tr4=cc[t4]+cc[t4]; + tr1=cc[t3]-cc[(t4+=t6)-1]; + tr2=cc[t3]+cc[t4-1]; + ch[t5]=tr2+tr3; + ch[t5+=t0]=tr1-tr4; + ch[t5+=t0]=tr2-tr3; + ch[t5+=t0]=tr1+tr4; + t1+=ido; + t3+=t2; + } + + if (ido<2) return; + if (ido==2) goto L105; + + t1=0; + for (k=0;k<l1;k++){ + t5=(t4=(t3=(t2=t1<<2)+t6))+t6; + t7=t1; + for (i=2;i<ido;i+=2){ + t2+=2; + t3+=2; + t4-=2; + t5-=2; + t7+=2; + ti1=cc[t2]+cc[t5]; + ti2=cc[t2]-cc[t5]; + ti3=cc[t3]-cc[t4]; + tr4=cc[t3]+cc[t4]; + tr1=cc[t2-1]-cc[t5-1]; + tr2=cc[t2-1]+cc[t5-1]; + ti4=cc[t3-1]-cc[t4-1]; + tr3=cc[t3-1]+cc[t4-1]; + ch[t7-1]=tr2+tr3; + cr3=tr2-tr3; + ch[t7]=ti2+ti3; + ci3=ti2-ti3; + cr2=tr1-tr4; + cr4=tr1+tr4; + ci2=ti1+ti4; + ci4=ti1-ti4; + + ch[(t8=t7+t0)-1]=wa1[i-2]*cr2-wa1[i-1]*ci2; + ch[t8]=wa1[i-2]*ci2+wa1[i-1]*cr2; + ch[(t8+=t0)-1]=wa2[i-2]*cr3-wa2[i-1]*ci3; + ch[t8]=wa2[i-2]*ci3+wa2[i-1]*cr3; + ch[(t8+=t0)-1]=wa3[i-2]*cr4-wa3[i-1]*ci4; + ch[t8]=wa3[i-2]*ci4+wa3[i-1]*cr4; + } + t1+=ido; + } + + if (ido%2 == 1) return; + + L105: + + t1=ido; + t2=ido<<2; + t3=ido-1; + t4=ido+(ido<<1); + for (k=0;k<l1;k++){ + t5=t3; + ti1=cc[t1]+cc[t4]; + ti2=cc[t4]-cc[t1]; + tr1=cc[t1-1]-cc[t4-1]; + tr2=cc[t1-1]+cc[t4-1]; + ch[t5]=tr2+tr2; + ch[t5+=t0]=sqrt2*(tr1-ti1); + ch[t5+=t0]=ti2+ti2; + ch[t5+=t0]=-sqrt2*(tr1+ti1); + + t3+=ido; + t1+=t2; + t4+=t2; + } +} + +STIN void dradbg(int ido,int ip,int l1,int idl1,float *cc,float *c1, + float *c2,float *ch,float *ch2,float *wa){ + static float tpi=6.28318530717958647692528676655900577; + int idij,ipph,i,j,k,l,ik,is,t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10, + t11,t12; + float dc2,ai1,ai2,ar1,ar2,ds2; + int nbd; + float dcp,arg,dsp,ar1h,ar2h; + int ipp2; + + t10=ip*ido; + t0=l1*ido; + arg=tpi/(float)ip; + dcp=cos(arg); + dsp=sin(arg); + nbd=(ido-1)>>1; + ipp2=ip; + ipph=(ip+1)>>1; + if (ido<l1) goto L103; + + t1=0; + t2=0; + for (k=0;k<l1;k++){ + t3=t1; + t4=t2; + for (i=0;i<ido;i++){ + ch[t3]=cc[t4]; + t3++; + t4++; + } + t1+=ido; + t2+=t10; + } + goto L106; + + L103: + t1=0; + for (i=0;i<ido;i++){ + t2=t1; + t3=t1; + for (k=0;k<l1;k++){ + ch[t2]=cc[t3]; + t2+=ido; + t3+=t10; + } + t1++; + } + + L106: + t1=0; + t2=ipp2*t0; + t7=(t5=ido<<1); + for (j=1;j<ipph;j++){ + t1+=t0; + t2-=t0; + t3=t1; + t4=t2; + t6=t5; + for (k=0;k<l1;k++){ + ch[t3]=cc[t6-1]+cc[t6-1]; + ch[t4]=cc[t6]+cc[t6]; + t3+=ido; + t4+=ido; + t6+=t10; + } + t5+=t7; + } + + if (ido == 1) goto L116; + if (nbd<l1) goto L112; + + t1=0; + t2=ipp2*t0; + t7=0; + for (j=1;j<ipph;j++){ + t1+=t0; + t2-=t0; + t3=t1; + t4=t2; + + t7+=(ido<<1); + t8=t7; + for (k=0;k<l1;k++){ + t5=t3; + t6=t4; + t9=t8; + t11=t8; + for (i=2;i<ido;i+=2){ + t5+=2; + t6+=2; + t9+=2; + t11-=2; + ch[t5-1]=cc[t9-1]+cc[t11-1]; + ch[t6-1]=cc[t9-1]-cc[t11-1]; + ch[t5]=cc[t9]-cc[t11]; + ch[t6]=cc[t9]+cc[t11]; + } + t3+=ido; + t4+=ido; + t8+=t10; + } + } + goto L116; + + L112: + t1=0; + t2=ipp2*t0; + t7=0; + for (j=1;j<ipph;j++){ + t1+=t0; + t2-=t0; + t3=t1; + t4=t2; + t7+=(ido<<1); + t8=t7; + t9=t7; + for (i=2;i<ido;i+=2){ + t3+=2; + t4+=2; + t8+=2; + t9-=2; + t5=t3; + t6=t4; + t11=t8; + t12=t9; + for (k=0;k<l1;k++){ + ch[t5-1]=cc[t11-1]+cc[t12-1]; + ch[t6-1]=cc[t11-1]-cc[t12-1]; + ch[t5]=cc[t11]-cc[t12]; + ch[t6]=cc[t11]+cc[t12]; + t5+=ido; + t6+=ido; + t11+=t10; + t12+=t10; + } + } + } + +L116: + ar1=1.; + ai1=0.; + t1=0; + t9=(t2=ipp2*idl1); + t3=(ip-1)*idl1; + for (l=1;l<ipph;l++){ + t1+=idl1; + t2-=idl1; + + ar1h=dcp*ar1-dsp*ai1; + ai1=dcp*ai1+dsp*ar1; + ar1=ar1h; + t4=t1; + t5=t2; + t6=0; + t7=idl1; + t8=t3; + for (ik=0;ik<idl1;ik++){ + c2[t4++]=ch2[t6++]+ar1*ch2[t7++]; + c2[t5++]=ai1*ch2[t8++]; + } + dc2=ar1; + ds2=ai1; + ar2=ar1; + ai2=ai1; + + t6=idl1; + t7=t9-idl1; + for (j=2;j<ipph;j++){ + t6+=idl1; + t7-=idl1; + ar2h=dc2*ar2-ds2*ai2; + ai2=dc2*ai2+ds2*ar2; + ar2=ar2h; + t4=t1; + t5=t2; + t11=t6; + t12=t7; + for (ik=0;ik<idl1;ik++){ + c2[t4++]+=ar2*ch2[t11++]; + c2[t5++]+=ai2*ch2[t12++]; + } + } + } + + t1=0; + for (j=1;j<ipph;j++){ + t1+=idl1; + t2=t1; + for (ik=0;ik<idl1;ik++)ch2[ik]+=ch2[t2++]; + } + + t1=0; + t2=ipp2*t0; + for (j=1;j<ipph;j++){ + t1+=t0; + t2-=t0; + t3=t1; + t4=t2; + for (k=0;k<l1;k++){ + ch[t3]=c1[t3]-c1[t4]; + ch[t4]=c1[t3]+c1[t4]; + t3+=ido; + t4+=ido; + } + } + + if (ido==1) goto L132; + if (nbd<l1) goto L128; + + t1=0; + t2=ipp2*t0; + for (j=1;j<ipph;j++){ + t1+=t0; + t2-=t0; + t3=t1; + t4=t2; + for (k=0;k<l1;k++){ + t5=t3; + t6=t4; + for (i=2;i<ido;i+=2){ + t5+=2; + t6+=2; + ch[t5-1]=c1[t5-1]-c1[t6]; + ch[t6-1]=c1[t5-1]+c1[t6]; + ch[t5]=c1[t5]+c1[t6-1]; + ch[t6]=c1[t5]-c1[t6-1]; + } + t3+=ido; + t4+=ido; + } + } + goto L132; + + L128: + t1=0; + t2=ipp2*t0; + for (j=1;j<ipph;j++){ + t1+=t0; + t2-=t0; + t3=t1; + t4=t2; + for (i=2;i<ido;i+=2){ + t3+=2; + t4+=2; + t5=t3; + t6=t4; + for (k=0;k<l1;k++){ + ch[t5-1]=c1[t5-1]-c1[t6]; + ch[t6-1]=c1[t5-1]+c1[t6]; + ch[t5]=c1[t5]+c1[t6-1]; + ch[t6]=c1[t5]-c1[t6-1]; + t5+=ido; + t6+=ido; + } + } + } + +L132: + if (ido==1) return; + + for (ik=0;ik<idl1;ik++)c2[ik]=ch2[ik]; + + t1=0; + for (j=1;j<ip;j++){ + t2=(t1+=t0); + for (k=0;k<l1;k++){ + c1[t2]=ch[t2]; + t2+=ido; + } + } + + if (nbd>l1) goto L139; + + is= -ido-1; + t1=0; + for (j=1;j<ip;j++){ + is+=ido; + t1+=t0; + idij=is; + t2=t1; + for (i=2;i<ido;i+=2){ + t2+=2; + idij+=2; + t3=t2; + for (k=0;k<l1;k++){ + c1[t3-1]=wa[idij-1]*ch[t3-1]-wa[idij]*ch[t3]; + c1[t3]=wa[idij-1]*ch[t3]+wa[idij]*ch[t3-1]; + t3+=ido; + } + } + } + return; + + L139: + is= -ido-1; + t1=0; + for (j=1;j<ip;j++){ + is+=ido; + t1+=t0; + t2=t1; + for (k=0;k<l1;k++){ + idij=is; + t3=t2; + for (i=2;i<ido;i+=2){ + idij+=2; + t3+=2; + c1[t3-1]=wa[idij-1]*ch[t3-1]-wa[idij]*ch[t3]; + c1[t3]=wa[idij-1]*ch[t3]+wa[idij]*ch[t3-1]; + } + t2+=ido; + } + } +} + +STIN void drftb1(int n, float *c, float *ch, float *wa, int *ifac){ + int i,k1,l1,l2; + int na; + int nf,ip,iw,ix2,ix3,ido,idl1; + + nf=ifac[1]; + na=0; + l1=1; + iw=1; + + for (k1=0;k1<nf;k1++){ + ip=ifac[k1 + 2]; + l2=ip*l1; + ido=n/l2; + idl1=ido*l1; + if (ip!=4) goto L103; + ix2=iw+ido; + ix3=ix2+ido; + + if (na!=0) + dradb4(ido,l1,ch,c,wa+iw-1,wa+ix2-1,wa+ix3-1); + else + dradb4(ido,l1,c,ch,wa+iw-1,wa+ix2-1,wa+ix3-1); + na=1-na; + goto L115; + + L103: + if (ip!=2) goto L106; + + if (na!=0) + dradb2(ido,l1,ch,c,wa+iw-1); + else + dradb2(ido,l1,c,ch,wa+iw-1); + na=1-na; + goto L115; + + L106: + if (ip!=3) goto L109; + + ix2=iw+ido; + if (na!=0) + dradb3(ido,l1,ch,c,wa+iw-1,wa+ix2-1); + else + dradb3(ido,l1,c,ch,wa+iw-1,wa+ix2-1); + na=1-na; + goto L115; + + L109: +/* The radix five case can be translated later..... */ +/* if (ip!=5) goto L112; + + ix2=iw+ido; + ix3=ix2+ido; + ix4=ix3+ido; + if (na!=0) + dradb5(ido,l1,ch,c,wa+iw-1,wa+ix2-1,wa+ix3-1,wa+ix4-1); + else + dradb5(ido,l1,c,ch,wa+iw-1,wa+ix2-1,wa+ix3-1,wa+ix4-1); + na=1-na; + goto L115; + + L112:*/ + if (na!=0) + dradbg(ido,ip,l1,idl1,ch,ch,ch,c,c,wa+iw-1); + else + dradbg(ido,ip,l1,idl1,c,c,c,ch,ch,wa+iw-1); + if (ido==1)na=1-na; + + L115: + l1=l2; + iw+=(ip-1)*ido; + } + + if (na==0) return; + + for (i=0;i<n;i++)c[i]=ch[i]; +} + +void __ogg_fdrfftb(int n, float *r, float *wsave, int *ifac){ + if (n == 1) return; + drftb1(n, r, wsave, wsave+n, ifac); +} + +STIN void dcsqb1(int n,float *x,float *w,float *xh,int *ifac){ + int modn,i,k,kc; + int np2,ns2; + float xim1; + + ns2=(n+1)>>1; + np2=n; + + for (i=2;i<n;i+=2){ + xim1=x[i-1]+x[i]; + x[i]-=x[i-1]; + x[i-1]=xim1; + } + + x[0]+=x[0]; + modn=n%2; + if (modn==0)x[n-1]+=x[n-1]; + + __ogg_fdrfftb(n,x,xh,ifac); + + kc=np2; + for (k=1;k<ns2;k++){ + kc--; + xh[k]=w[k-1]*x[kc]+w[kc-1]*x[k]; + xh[kc]=w[k-1]*x[k]-w[kc-1]*x[kc]; + } + + if (modn==0)x[ns2]=w[ns2-1]*(x[ns2]+x[ns2]); + + kc=np2; + for (k=1;k<ns2;k++){ + kc--; + x[k]=xh[k]+xh[kc]; + x[kc]=xh[k]-xh[kc]; + } + x[0]+=x[0]; +} + +void __ogg_fdcosqb(int n,float *x,float *wsave,int *ifac){ + static float tsqrt2 = 2.8284271247461900976033774484194; + float x1; + + if (n<2){ + x[0]*=4; + return; + } + if (n==2){ + x1=(x[0]+x[1])*4; + x[1]=tsqrt2*(x[0]-x[1]); + x[0]=x1; + return; + } + + dcsqb1(n,x,wsave,wsave+n,ifac); +} + + + diff --git a/demos/mobile/guitartuner/src/guitartuner.cpp b/demos/mobile/guitartuner/src/guitartuner.cpp new file mode 100644 index 0000000..1750e6a --- /dev/null +++ b/demos/mobile/guitartuner/src/guitartuner.cpp @@ -0,0 +1,359 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "guitartuner.h" + +#ifdef Q_OS_SYMBIAN +#include <SoundDevice.h> +#endif // Q_OS_SYMBIAN + +#if defined(Q_OS_SYMBIAN) && defined(ORIENTATIONLOCK) +#include <eikenv.h> +#include <eikappui.h> +#include <aknenv.h> +#include <aknappui.h> +#endif // Q_OS_SYMBIAN && ORIENTATIONLOCK + +GuitarTuner::GuitarTuner(QWidget *parent) : + QMainWindow(parent) +{ + + // Set up the QML. + m_guitarTunerUI = new QDeclarativeView(QUrl("qrc:/src/application.qml"), this); + setCentralWidget(m_guitarTunerUI); + m_guitarTunerUI->setResizeMode(QDeclarativeView::SizeRootObjectToView); + qmlObject = m_guitarTunerUI->rootObject(); + + // Init audio output and input. + initAudioOutput(); + initAudioInput(); + + // Connect the quit signal of m_guitarTunerUI + // into the close slot of this. + connect(m_guitarTunerUI->engine(), SIGNAL(quit()), SLOT(close())); + + // Connect the signals from qmlObject into proper slots + // of this and m_voicegenerator. + connect(qmlObject, SIGNAL(muteStateChanged(bool)), + SLOT(muteStateChanged(bool))); + connect(qmlObject, SIGNAL(volumeChanged(qreal)), + m_voicegenerator, SLOT(setAmplitude(qreal))); + connect(qmlObject, SIGNAL(volumeChanged(qreal)), + SLOT(setMaxVolumeLevel(qreal))); + + // Connect the modeChanged signal from qmlObject + // into modeChanged slot of this class. + connect(qmlObject, SIGNAL(modeChanged(bool)), + SLOT(modeChanged(bool))); + + // Connect the microphoneSensitivityChanged signal from + // m_guitarTunerUI into setCutOffPercentage slot of m_analyzer class. + connect(qmlObject, SIGNAL(microphoneSensitivityChanged(qreal)), + m_analyzer, SLOT(setCutOffPercentage(qreal))); + + // Connect the signals from m_analyzer into slots of qmlObject. + connect(m_analyzer, SIGNAL(lowVoice()), + qmlObject, SLOT(lowVoice())); + connect(m_analyzer, SIGNAL(correctFrequency()), + qmlObject, SLOT(correctFrequencyObtained())); + connect(m_analyzer, SIGNAL(voiceDifference(QVariant)), + qmlObject, SLOT(voiceDifferenceChanged(QVariant))); + + // Initialise the MaximumVoiceDifference + // value of qmlObject with the value obtained from m_analyzer. + qmlObject->setProperty("maxVoiceDifference", + m_analyzer->getMaximumVoiceDifference()); + + // Connect the targetFrequencyChanged signal of qmlObject + // into targetFrequencyChanged slot of this class. + connect(qmlObject, SIGNAL(targetFrequencyChanged(qreal)), + SLOT(targetFrequencyChanged(qreal))); + + // Start voice output or input by using the modeChanged function, + // depending of the current mode. + modeChanged(qmlObject->property("isInput").toBool()); + +} + +/** + * Inits audio output. + */ +void GuitarTuner::initAudioOutput() +{ + // Set up the output format. + m_format_output.setFrequency(DataFrequencyHzOutput); + m_format_output.setCodec("audio/pcm"); + m_format_output.setSampleSize(16); + m_format_output.setChannels(1); + m_format_output.setByteOrder(QAudioFormat::LittleEndian); + m_format_output.setSampleType(QAudioFormat::SignedInt); + + // Obtain a default output device, and if the format is not + // supported, find the nearest format available. + QAudioDeviceInfo outputDeviceInfo( + QAudioDeviceInfo::defaultOutputDevice()); + if (!outputDeviceInfo.isFormatSupported(m_format_output)) { + m_format_output = outputDeviceInfo.nearestFormat(m_format_output); + } + + // Create new QAudioOutput and VoiceGenerator instances, and store + // them in m_audioOutput and m_voicegenerator, respectively. + m_audioOutput = new QAudioOutput(outputDeviceInfo, + m_format_output, this); + m_voicegenerator = new VoiceGenerator(m_format_output, + qmlObject->property("frequency").toReal(), + qmlObject->property("volume").toReal(), + this); + + // Connect m_audioOutput stateChanged signal to outputStateChanged. + connect(m_audioOutput, SIGNAL(stateChanged(QAudio::State)), + SLOT(outputStateChanged(QAudio::State))); +} + +/** + * Inits audio input. + */ +void GuitarTuner::initAudioInput() +{ + // Set up the input format. + m_format_input.setFrequency(DataFrequencyHzInput); + m_format_input.setCodec("audio/pcm"); + m_format_input.setSampleSize(16); + m_format_input.setChannels(1); + m_format_input.setByteOrder(QAudioFormat::LittleEndian); + m_format_input.setSampleType(QAudioFormat::SignedInt); + + // Obtain a default input device, and if the format is not + // supported, find the nearest format available. + QAudioDeviceInfo inputDeviceInfo( + QAudioDeviceInfo::defaultInputDevice()); + if (!inputDeviceInfo.isFormatSupported(m_format_input)) { + m_format_input = inputDeviceInfo.nearestFormat(m_format_input); + } + + // Create new QAudioInput and VoiceAnalyzer instances, and store + // them in m_audioInput and m_analyzer, respectively. + // Remember to set the cut-off percentage for voice analyzer. + m_audioInput = new QAudioInput(inputDeviceInfo, m_format_input, this); + m_analyzer = new VoiceAnalyzer(m_format_input, this); + m_analyzer->setCutOffPercentage(qmlObject->property("sensitivity").toReal()); + +} + +/** + * Receives a mode changed signal. + */ +void GuitarTuner::modeChanged(bool isInput) +{ + + + + // If the mode must be changed to input mode: + if (isInput) { + + // Stop audio output and audio generator. + m_audioOutput->stop(); + m_voicegenerator->stop(); + // Start the audio analyzer and then the audio input. + m_analyzer->start(qmlObject->property("frequency").toReal()); + m_audioInput->start(m_analyzer); + + } + // Else: + else { + + // Stop audio input and audio analyzer. + m_audioInput->stop(); + m_analyzer->stop(); + + // Set up the audio output. + + // If the current frequency of voice generator + // is not the same as the target frequency selected in the UI, + // update voice generator's frequency. + if (m_voicegenerator->frequency() != qmlObject->property("frequency").toReal()) { + m_voicegenerator->setFrequency(qmlObject->property("frequency").toReal()); + } + + // Start the voice generator and then the audio output. + m_voicegenerator->start(); + m_audioOutput->start(m_voicegenerator); + // Call setMaxVolumeLevel(1) to set the maximum volume louder. + setMaxVolumeLevel(qmlObject->property("volume").toReal()); + + // If the voice is muted, the voice is suspended + // in the outputStateChanged slot. + + } +} + +/** + * Receives a output state changed signal. + * Suspends the audio output, if the state is ActiveState + * and the voice is muted. + */ +void GuitarTuner::outputStateChanged(QAudio::State state) +{ + if (QAudio::ActiveState == state && qmlObject->property("isMuted").toBool()) { + // If the voice is muted, suspend the voice. + m_audioOutput->suspend(); + } +} + +/** + * Receives a mute state changed signal. + * Suspends the audio output or resumes it, depending of the + * isMuted parameter. + */ +void GuitarTuner::muteStateChanged(bool isMuted) +{ + if (isMuted) { + m_audioOutput->suspend(); + } + else { + m_audioOutput->resume(); + } +} + +/** + * Receives a target frequency signal. + */ +void GuitarTuner::targetFrequencyChanged(qreal targetFrequency) +{ + // If the output mode is active: + if (!qmlObject->property("isInput").toBool()) { + // Stop the audio output and voice generator. + m_audioOutput->stop(); + m_voicegenerator->stop(); + // Set the voice generator's frequency to the target frequency. + m_voicegenerator->setFrequency(targetFrequency); + // Start the voice generator and audio output. + m_voicegenerator->start(); + m_audioOutput->start(m_voicegenerator); + // Call setMaxVolumeLevel(1) to set the maximum volume louder. + setMaxVolumeLevel(qmlObject->property("volume").toReal()); + + // If the voice is muted, the voice is suspended + // in the outputStateChanged slot. + + } + // Else: + else { + + // Stop the audio input and voice analyzer. + m_audioInput->stop(); + m_analyzer->stop(); + // Start the voice analyzer with new frequency and audio input. + m_analyzer->start(targetFrequency); + m_audioInput->start(m_analyzer); + + } +} + +/** + * This method provides a hack to set the maximum volume level in + * Symbian. + */ +void GuitarTuner::setMaxVolumeLevel(qreal percent) +{ + if (percent >= 1.0) { + percent = 1.0; + } + else if (percent <= 0.0) { + percent = 0.0; + } + percent = percent*0.5 + 0.5; + // Warning! This is a hack, which can break when the QtMobility + // changes. Use at your own risk. +#ifdef Q_OS_SYMBIAN + unsigned int *pointer_to_abstract_audio + = (unsigned int*)( (unsigned char*)m_audioOutput + 8 ); + unsigned int *dev_sound_wrapper + = (unsigned int*)(*pointer_to_abstract_audio) + 16; + unsigned int *temp + = ((unsigned int*)(*dev_sound_wrapper) + 6); + CMMFDevSound *dev_sound = (CMMFDevSound*)(*temp); + dev_sound->SetVolume((unsigned int) + (percent*(float)dev_sound->MaxVolume())); +#endif +} + +/** + * A function used to lock the orientation. + */ +void GuitarTuner::setOrientation(Orientation orientation) +{ +#ifdef Q_OS_SYMBIAN + if (orientation != Auto) { +#if defined(ORIENTATIONLOCK) + const CAknAppUiBase::TAppUiOrientation uiOrientation = + (orientation == LockPortrait) + ? CAknAppUi::EAppUiOrientationPortrait + : CAknAppUi::EAppUiOrientationLandscape; + CAknAppUi* appUi = dynamic_cast<CAknAppUi*> + (CEikonEnv::Static()->AppUi()); + TRAPD(error, + if (appUi) + appUi->SetOrientationL(uiOrientation); + ); +#else // ORIENTATIONLOCK + qWarning(QString("'ORIENTATIONLOCK' needs to be defined on") + +QString(" Symbian when locking the orientation.")); +#endif // ORIENTATIONLOCK + } +#elif defined(Q_WS_MAEMO_5) + Qt::WidgetAttribute attribute; + switch (orientation) { + case LockPortrait: + attribute = Qt::WA_Maemo5PortraitOrientation; + break; + case LockLandscape: + attribute = Qt::WA_Maemo5LandscapeOrientation; + break; + case Auto: + default: + attribute = Qt::WA_Maemo5AutoOrientation; + break; + } + setAttribute(attribute, true); +#else // Q_OS_SYMBIAN + Q_UNUSED(orientation); +#endif // Q_OS_SYMBIAN +} diff --git a/demos/mobile/guitartuner/src/guitartuner.h b/demos/mobile/guitartuner/src/guitartuner.h new file mode 100644 index 0000000..aa3e9f8 --- /dev/null +++ b/demos/mobile/guitartuner/src/guitartuner.h @@ -0,0 +1,95 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef MAINWINDOW_H +#define MAINWINDOW_H + +#include <QMainWindow> +#include <QtDeclarative> +#include <QAudioDeviceInfo> +#include <QAudioOutput> +#include <QAudioInput> +#include "voicegenerator.h" +#include "voiceanalyzer.h" + +const int DataFrequencyHzOutput = 44100; +const int DataFrequencyHzInput = 48000; + +#define MAX_INPUT_VALUE 50 +#define MIN_INPUT_VALUE -50 + +class GuitarTuner : public QMainWindow +{ + Q_OBJECT +public: + enum Orientation { + LockPortrait, + LockLandscape, + Auto + }; + explicit GuitarTuner(QWidget *parent = 0); + qreal getVolume(); + qreal getMicrophoneSensitivity(); + bool getMuteState(); + void setOrientation(Orientation orientation); + +signals: + +public slots: + void modeChanged(bool isInput); + void muteStateChanged(bool isMuted); + void targetFrequencyChanged(qreal targetFrequency); + void outputStateChanged(QAudio::State state); + void setMaxVolumeLevel(qreal); + +private: + void initAudioOutput(); + void initAudioInput(); + VoiceGenerator *m_voicegenerator; + VoiceAnalyzer *m_analyzer; + QObject *qmlObject; + QAudioOutput *m_audioOutput; + QAudioInput *m_audioInput; + QAudioFormat m_format_output; + QAudioFormat m_format_input; + QDeclarativeView *m_guitarTunerUI; +}; + +#endif // MAINWINDOW_H diff --git a/demos/mobile/guitartuner/src/guitartuner.rc b/demos/mobile/guitartuner/src/guitartuner.rc new file mode 100644 index 0000000..85cee0b --- /dev/null +++ b/demos/mobile/guitartuner/src/guitartuner.rc @@ -0,0 +1,23 @@ +IDI_ICON1 ICON DISCARDABLE "/../images/guitartuner_icon.ico" + +1 VERSIONINFO +FILEVERSION 1,2,0,0 +PRODUCTVERSION 1,2,0,0 +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904E4" + BEGIN + VALUE "CompanyName", "Nokia Corporation\0" + VALUE "FileDescription", "Qt Quick example application.\0" + VALUE "FileVersion", "1.2.0\0" + VALUE "LegalCopyright", "Copyright 2011 Nokia Corporation. All rights reserved.\0" + VALUE "ProductName", "Guitar Tuner\0" + VALUE "ProductVersion", "1.2.0\0" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1252 + END +END
\ No newline at end of file diff --git a/demos/mobile/guitartuner/src/guitartuner.ui b/demos/mobile/guitartuner/src/guitartuner.ui new file mode 100644 index 0000000..36ee1bd --- /dev/null +++ b/demos/mobile/guitartuner/src/guitartuner.ui @@ -0,0 +1,178 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>GuitarTuner</class> + <widget class="QWidget" name="GuitarTuner"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>187</width> + <height>279</height> + </rect> + </property> + <property name="windowTitle"> + <string>GuitarTuner</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout_2"> + <item> + <widget class="QLabel" name="tabulatorIcon"> + <property name="text"> + <string notr="true"/> + </property> + <property name="pixmap"> + <pixmap resource="../guitartuner.qrc">:/images/guitartab.svg</pixmap> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + </widget> + </item> + <item> + <widget class="QSlider" name="correctSoundSlider"> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="autoFillBackground"> + <bool>false</bool> + </property> + <property name="minimum"> + <number>-50</number> + </property> + <property name="maximum"> + <number>50</number> + </property> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="tickPosition"> + <enum>QSlider::TicksAbove</enum> + </property> + <property name="tickInterval"> + <number>50</number> + </property> + </widget> + </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <widget class="QToolButton" name="buttonPrev"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>...</string> + </property> + <property name="arrowType"> + <enum>Qt::LeftArrow</enum> + </property> + </widget> + </item> + <item> + <widget class="QLabel" name="noteLabel"> + <property name="text"> + <string>A</string> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + </widget> + </item> + <item> + <widget class="QToolButton" name="buttonNext"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>...</string> + </property> + <property name="autoRaise"> + <bool>false</bool> + </property> + <property name="arrowType"> + <enum>Qt::RightArrow</enum> + </property> + </widget> + </item> + </layout> + </item> + <item> + <widget class="QPushButton" name="modeButton"> + <property name="text"> + <string>Change mode</string> + </property> + </widget> + </item> + <item> + <widget class="Line" name="line"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + </widget> + </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout_2"> + <item> + <widget class="QSlider" name="soundSlider"> + <property name="value"> + <number>65</number> + </property> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + </widget> + </item> + <item> + <widget class="QToolButton" name="soundButton"> + <property name="text"> + <string>...</string> + </property> + <property name="icon"> + <iconset resource="../guitartuner.qrc"> + <normaloff>:/images/note.svg</normaloff> + <normalon>:/images/noteNo.svg</normalon> + <activeon>:/images/noteNo.svg</activeon>:/images/note.svg</iconset> + </property> + <property name="iconSize"> + <size> + <width>30</width> + <height>30</height> + </size> + </property> + <property name="checkable"> + <bool>true</bool> + </property> + <property name="autoRaise"> + <bool>true</bool> + </property> + </widget> + </item> + <item> + <widget class="QLabel" name="micSensitivityLabel"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>microphone +sensitivity</string> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </widget> + <layoutdefault spacing="6" margin="11"/> + <resources> + <include location="../guitartuner.qrc"/> + </resources> + <connections/> +</ui> diff --git a/demos/mobile/guitartuner/src/guitartunerui.cpp b/demos/mobile/guitartuner/src/guitartunerui.cpp new file mode 100644 index 0000000..9d59d7c --- /dev/null +++ b/demos/mobile/guitartuner/src/guitartunerui.cpp @@ -0,0 +1,341 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QTimer> + +#include "guitartunerui.h" +#include "ui_guitartunerui.h" + +GuitarTunerUI::GuitarTunerUI(QWidget *parent) : + QWidget(parent), + ui(new Ui::GuitarTunerUI), + m_maximumPrecision(0) +{ + ui->setupUi(this); + + // Set up the class attributes to proper values. + m_outputActive = false; + m_muted = false; + m_outputVolumeLevel = getVolumeFromSoundSlider(); + m_inputVolumeLevel = 1.0 - m_outputVolumeLevel; + + // Set up the current tone, the frequency, and the name for it. + m_currentToneIndex = 5; + updateFrequencyByToneIndex(m_currentToneIndex); + + // Connect the signals from UI into proper slots. + connect(ui->soundSlider, SIGNAL(valueChanged(int)), + SLOT(changeVolume())); + connect(ui->soundButton, SIGNAL(toggled(bool)), + SLOT(toggleSound(bool))); + connect(ui->modeButton, SIGNAL(clicked()), + SLOT(toggleInputOrOutput())); + connect(ui->buttonNext, SIGNAL(clicked()), SLOT(next())); + connect(ui->buttonPrev, SIGNAL(clicked()), SLOT(prev())); + + // Initialise up the UI by calling toggleInputOrOutput + // for the first time. + toggleInputOrOutput(); +} + +GuitarTunerUI::~GuitarTunerUI() +{ + delete ui; +} + +void GuitarTunerUI::changeEvent(QEvent *e) +{ + QWidget::changeEvent(e); + switch (e->type()) { + case QEvent::LanguageChange: + ui->retranslateUi(this); + break; + default: + break; + } +} + +/** + * Returns a value from 0 to 1, representing the volume. + */ +qreal GuitarTunerUI::getVolumeFromSoundSlider() const +{ + qreal value = ui->soundSlider->value(); + return value/ui->soundSlider->maximum(); +} + +/** + * Updates the m_currentToneFrequency and m_currentToneString, + * according to the given index. Also updates the UI. + */ +void GuitarTunerUI::updateFrequencyByToneIndex(int index) +{ + + switch (index) { + case 0: { + m_currentToneFrequency = FrequencyE; + m_currentToneString = "E"; + break; + } + case 1: { + m_currentToneFrequency = FrequencyA; + m_currentToneString = "A"; + break; + } + case 2: { + m_currentToneFrequency = FrequencyD; + m_currentToneString = "D"; + break; + } + case 3: { + m_currentToneFrequency = FrequencyG; + m_currentToneString = "G"; + break; + } + case 4: { + m_currentToneFrequency = FrequencyB; + m_currentToneString = "B"; + break; + } + case 5: { + m_currentToneFrequency = FrequencyE2; + m_currentToneString = "e"; + break; + } + default: { + qDebug() << "invalid index!" << index; + } + } + // Set the noteLabel text according to the current tone. + ui->noteLabel->setText(m_currentToneString); +} + +/** + * Returns the volume. + */ +qreal GuitarTunerUI::getVolume() const +{ + return m_outputVolumeLevel; +} + +/** + * Returns true if the sound is muted. + */ +bool GuitarTunerUI::getMuteState() const +{ + return m_muted; +} + + +/** + * Returns the microphone sensitivity. + */ +qreal GuitarTunerUI::getMicrophoneSensitivity() const +{ + return m_inputVolumeLevel; +} + +/** + * Returns whether the input mode is active. + */ +bool GuitarTunerUI::isInputModeActive() const +{ + return !m_outputActive; +} + +/** + * Returns the current target frequency. + */ +qreal GuitarTunerUI::getFrequency() const +{ + return m_currentToneFrequency; +} + +/** + * Toggles the sound according to the parameter. + * Has no effect if output is not active. + */ +void GuitarTunerUI::toggleSound(bool noSound) +{ + if (!m_outputActive) { + return; + } + m_muted = noSound; + emit muteChanged(m_muted); +} + +/** + * Changes the volume or microphone sensitivity. + */ +void GuitarTunerUI::changeVolume() +{ + qreal resultingAmplitude = getVolumeFromSoundSlider(); + qDebug() << "resultingAmplitude" << resultingAmplitude; + if (m_outputActive) { + m_outputVolumeLevel = resultingAmplitude; + emit volumeChanged(resultingAmplitude); + } + else { + m_inputVolumeLevel = resultingAmplitude; + emit microphoneSensitivityChanged(1.0-resultingAmplitude); + } +} + +/** + * Toggles input or output, depending of the current state. + */ +void GuitarTunerUI::toggleInputOrOutput() +{ + // If output mode is active: + if (m_outputActive) { + // Change UI to correspond to the input mode. + m_outputActive = false; + ui->soundSlider->setValue(m_inputVolumeLevel*100); + ui->soundButton->setDisabled(true); + ui->soundButton->hide(); + ui->micSensitivityLabel->show(); + emit modeChanged(true); + ui->modeButton->setText("To tone mode"); + } + // Else: + else { + // Change UI to correspond to the output mode. + m_outputActive = true; + ui->soundSlider->setValue(m_outputVolumeLevel*100); + ui->soundButton->setDisabled(false); + ui->micSensitivityLabel->hide(); + ui->soundButton->show(); + emit modeChanged(false); + ui->modeButton->setText("To listen mode"); + } +} + +/** + * Receives the low voice signal. + */ +void GuitarTunerUI::lowVoice() +{ + if (ui->noteLabel->font().bold()) { + QFont font; + font.setBold(false); + font.setUnderline(false); + ui->noteLabel->setFont(font); + } +} + +/** + * Receives the voice difference signal. + * The difference is qreal, where increase of 1 corresponds + * to increase of 1 tone to the target frequency. + */ +void GuitarTunerUI::voiceDifference(qreal difference) +{ + if (ui->noteLabel->font().bold()) { + QFont font; + font.setBold(false); + font.setUnderline(false); + ui->noteLabel->setFont(font); + } + ui->correctSoundSlider->setValue(difference*m_maximumPrecision); +} + +/** + * Receives the correct frequency signal. + * Makes the UI to visualize correct frequency event. + */ +void GuitarTunerUI::correctFrequencyObtained() +{ + qDebug() << "CORRECT FREQUENCY"; + QFont font; + font.setBold(true); + font.setUnderline(true); + ui->noteLabel->setFont(font); +} + +/** + * Sets up the maximum voice difference. + */ +void GuitarTunerUI::setMaximumVoiceDifference(int max) +{ + // Assert that the maximum precision is known. + Q_ASSERT(m_maximumPrecision != 0); + // Set the maximum and minimum values of the correctSoundSlider + // to the +- max*m_maximumPrecision, and set the tick interval + // to be m_maximumPrecision. + ui->correctSoundSlider->setMaximum(max*m_maximumPrecision); + ui->correctSoundSlider->setMinimum(-max*m_maximumPrecision); + ui->correctSoundSlider->setTickInterval(max*m_maximumPrecision); +} + +/** + * Stores the maximum precision per note. Used to setup the + * correct sound slider. + */ +void GuitarTunerUI::setMaximumPrecisionPerNote(int max) +{ + m_maximumPrecision = max; +} + +/** + * Changes the tone to the next value. + */ +void GuitarTunerUI::next() +{ + changeTone((m_currentToneIndex + 1) % 6); +} + +/** + * Changes the tone to the previous value. + */ +void GuitarTunerUI::prev() +{ + changeTone((m_currentToneIndex + 5) % 6); +} + +/** + * Changes the tone according to the new index. + */ +void GuitarTunerUI::changeTone(int newIndex) +{ + m_currentToneIndex = newIndex; + updateFrequencyByToneIndex(m_currentToneIndex); + qDebug() << "targetFrequencyChanged" << m_currentToneFrequency; + emit targetFrequencyChanged(m_currentToneFrequency); +} diff --git a/demos/mobile/guitartuner/src/guitartunerui.h b/demos/mobile/guitartuner/src/guitartunerui.h new file mode 100644 index 0000000..fa8e8f4 --- /dev/null +++ b/demos/mobile/guitartuner/src/guitartunerui.h @@ -0,0 +1,111 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef GUITARTUNERUI_H +#define GUITARTUNERUI_H + +#include <QWidget> +#include <QDebug> + +namespace Ui { + class GuitarTunerUI; +} + +const qreal FrequencyE = 82.407; +const qreal FrequencyA = 110.00; +const qreal FrequencyD = 146.83; +const qreal FrequencyG = 196.00; +const qreal FrequencyB = 246.94; +const qreal FrequencyE2 = 329.63; + +class GuitarTunerUI : public QWidget +{ + Q_OBJECT + +public: + explicit GuitarTunerUI(QWidget *parent = 0); + ~GuitarTunerUI(); + + qreal getVolume() const; + bool getMuteState() const; + qreal getMicrophoneSensitivity() const; + bool isInputModeActive() const; + qreal getFrequency() const; + int getScaleMaximumValue() const; + void setMaximumVoiceDifference(int max); + void setMaximumPrecisionPerNote(int max); + +public slots: + void toggleSound(bool off); + void next(); + void prev(); + void changeVolume(); + void toggleInputOrOutput(); + + void lowVoice(); + void voiceDifference(qreal difference); + void correctFrequencyObtained(); + +signals: + void modeChanged(bool isInput); + void volumeChanged(qreal volume); + void microphoneSensitivityChanged(qreal sensitivity); + void muteChanged(bool isMuted); + void targetFrequencyChanged(qreal targetFrequency); + +protected: + void changeEvent(QEvent *e); + +private: + Ui::GuitarTunerUI *ui; + void changeTone(int newIndex); + qreal getVolumeFromSoundSlider() const; + int m_currentToneIndex; + QString m_currentToneString; + qreal m_currentToneFrequency; + void updateFrequencyByToneIndex(int index); + bool m_outputActive; + bool m_muted; + qreal m_outputVolumeLevel; + qreal m_inputVolumeLevel; + int m_maximumPrecision; +}; + +#endif // GUITARTUNERUI_H diff --git a/demos/mobile/guitartuner/src/guitartunerui.ui b/demos/mobile/guitartuner/src/guitartunerui.ui new file mode 100644 index 0000000..af7b585 --- /dev/null +++ b/demos/mobile/guitartuner/src/guitartunerui.ui @@ -0,0 +1,178 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>GuitarTunerUI</class> + <widget class="QWidget" name="GuitarTunerUI"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>187</width> + <height>279</height> + </rect> + </property> + <property name="windowTitle"> + <string>GuitarTunerUI</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout_2"> + <item> + <widget class="QLabel" name="tabulatorIcon"> + <property name="text"> + <string notr="true"/> + </property> + <property name="pixmap"> + <pixmap resource="../GuitarTuner.qrc">:/images/guitartab.svg</pixmap> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + </widget> + </item> + <item> + <widget class="QSlider" name="correctSoundSlider"> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="autoFillBackground"> + <bool>false</bool> + </property> + <property name="minimum"> + <number>-50</number> + </property> + <property name="maximum"> + <number>50</number> + </property> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="tickPosition"> + <enum>QSlider::TicksAbove</enum> + </property> + <property name="tickInterval"> + <number>50</number> + </property> + </widget> + </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <widget class="QToolButton" name="buttonPrev"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>...</string> + </property> + <property name="arrowType"> + <enum>Qt::LeftArrow</enum> + </property> + </widget> + </item> + <item> + <widget class="QLabel" name="noteLabel"> + <property name="text"> + <string>A</string> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + </widget> + </item> + <item> + <widget class="QToolButton" name="buttonNext"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>...</string> + </property> + <property name="autoRaise"> + <bool>false</bool> + </property> + <property name="arrowType"> + <enum>Qt::RightArrow</enum> + </property> + </widget> + </item> + </layout> + </item> + <item> + <widget class="QPushButton" name="modeButton"> + <property name="text"> + <string>Change mode</string> + </property> + </widget> + </item> + <item> + <widget class="Line" name="line"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + </widget> + </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout_2"> + <item> + <widget class="QSlider" name="soundSlider"> + <property name="value"> + <number>65</number> + </property> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + </widget> + </item> + <item> + <widget class="QToolButton" name="soundButton"> + <property name="text"> + <string>...</string> + </property> + <property name="icon"> + <iconset resource="../GuitarTuner.qrc"> + <normaloff>:/images/note.svg</normaloff> + <normalon>:/images/noteNo.svg</normalon> + <activeon>:/images/noteNo.svg</activeon>:/images/note.svg</iconset> + </property> + <property name="iconSize"> + <size> + <width>30</width> + <height>30</height> + </size> + </property> + <property name="checkable"> + <bool>true</bool> + </property> + <property name="autoRaise"> + <bool>true</bool> + </property> + </widget> + </item> + <item> + <widget class="QLabel" name="micSensitivityLabel"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>microphone +sensitivity</string> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </widget> + <layoutdefault spacing="6" margin="11"/> + <resources> + <include location="../GuitarTuner.qrc"/> + </resources> + <connections/> +</ui> diff --git a/demos/mobile/guitartuner/src/main.cpp b/demos/mobile/guitartuner/src/main.cpp new file mode 100644 index 0000000..33b1181 --- /dev/null +++ b/demos/mobile/guitartuner/src/main.cpp @@ -0,0 +1,60 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtGui/QApplication> +#include "guitartuner.h" + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + GuitarTuner w; + w.setOrientation(GuitarTuner::LockPortrait); + +#ifdef Q_OS_SYMBIAN + w.showFullScreen(); +#elif defined(Q_WS_MAEMO_5) || defined(Q_WS_MAEMO_6) + w.showMaximized(); +#else + w.show(); +#endif + + return a.exec(); +} + diff --git a/demos/mobile/guitartuner/src/mycomponents/Adjuster.qml b/demos/mobile/guitartuner/src/mycomponents/Adjuster.qml new file mode 100644 index 0000000..342e6f7 --- /dev/null +++ b/demos/mobile/guitartuner/src/mycomponents/Adjuster.qml @@ -0,0 +1,131 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 1.0 +import "adjustbars.js" as AdjustBars + +/* A barchart-like adjuster component. */ +Rectangle { + id: adjuster + + property real max: 100 + property real value: 0 + property bool created: false + + signal valueChanged(real value) + signal focusChangedByClick() + signal arrowPressedWhenValueOverLimits() + + function setValue(pValue) { + value = pValue; + AdjustBars.fillBars(value/max*AdjustBars.maxBars); + valueChanged(value); + } + + height: 60; width: 300 + color: "transparent" + Keys.onRightPressed: { + var val = value+max/AdjustBars.maxBars; + if (val <= max) { + value = val; + AdjustBars.fillBars(value/max*AdjustBars.maxBars); + valueChanged(value); + } + else { + arrowPressedWhenValueOverLimits() + } + } + Keys.onLeftPressed: { + var val = value-max/AdjustBars.maxBars; + if (0 <= val) { + value = val; + AdjustBars.fillBars(value/max*AdjustBars.maxBars); + valueChanged(value); + } + else { + arrowPressedWhenValueOverLimits() + } + } + Component.onCompleted: { + AdjustBars.createBars(); + AdjustBars.fillBars(value/max*AdjustBars.maxBars); + created = true; + } + Component.onDestruction: { + AdjustBars.destroyBars; + } + //Dynamic objects have to be recreated when the window size changes. + onWidthChanged: { + if (created) { + AdjustBars.destroyBars(); + AdjustBars.createBars(); + AdjustBars.fillBars(value/max*AdjustBars.maxBars); + } + } + onHeightChanged: { + if (created) { + AdjustBars.destroyBars(); + AdjustBars.createBars(); + AdjustBars.fillBars(value/max*AdjustBars.maxBars); + } + } + + MouseArea { + anchors.fill: parent + onPositionChanged: { + focusChangedByClick(); + var val = mouse.x/parent.width*parent.max; + if (0 < val && val < max) { + parent.value = val; + AdjustBars.fillBars(parent.value/parent.max*AdjustBars.maxBars); + valueChanged(parent.value); + } + } + onClicked: { + focusChangedByClick(); + var val = mouse.x/parent.width*parent.max; + if (0 < val && val < max) { + parent.value = val; + AdjustBars.fillBars(parent.value/parent.max*AdjustBars.maxBars); + valueChanged(parent.value); + } + } + } +} diff --git a/demos/mobile/guitartuner/src/mycomponents/Meter.qml b/demos/mobile/guitartuner/src/mycomponents/Meter.qml new file mode 100644 index 0000000..8a64711 --- /dev/null +++ b/demos/mobile/guitartuner/src/mycomponents/Meter.qml @@ -0,0 +1,112 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 1.0 + +/* A meter component. */ +Rectangle { + id: meter + + property real value: 0 + property real minValue: -1 + property real maxValue: 1 + property alias imageSize: meterImage.sourceSize + + function valueChanged(pValue) { + value = pValue; + scaleValueToAngle(); + } + function scaleValueToAngle() { + pointer.angle = (((value-minValue)/(maxValue-minValue))* + (pointer.angleMax-pointer.angleMin))+ + pointer.angleMin; + } + + color: "transparent" + + Image { + id: meterImage + + smooth: true + source: "./images/meterBG.png" + anchors.fill: parent + } + + Image { + id:pointerShadow + + x: pointer.x - 2 + y: pointer.y - 2 + height: pointer.height + smooth: true + source: "./images/pointerShadow.png" + transform: Rotation { + origin.x: 2 + origin.y: height + angle: -pointer.angle + } + } + + Image { + id: pointer + + property real angle: 0 + property real angleMax: -45 + property real angleMin: 45 + + height: parent.height*0.92 + transformOrigin: "Bottom" + rotation: -angle + smooth: true + source: "./images/pointer.png" + anchors { + bottomMargin: 2 + bottom: parent.bottom; + horizontalCenter: parent.horizontalCenter + } + + Behavior on angle { + SpringAnimation { + spring: 1.4 + damping: 0.15 + } + } + } +} diff --git a/demos/mobile/guitartuner/src/mycomponents/NoteButtonView.qml b/demos/mobile/guitartuner/src/mycomponents/NoteButtonView.qml new file mode 100644 index 0000000..fc64fe5 --- /dev/null +++ b/demos/mobile/guitartuner/src/mycomponents/NoteButtonView.qml @@ -0,0 +1,84 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 1.0 + +/* A view component for buttons for choosing notes. */ +ListView { + id: noteChooser + + property real currentFrequency: 82.407 + + signal noteSelected(string note, real frequency, int index) + + //Press down the button corresponding to the given note. + function pushButton(index) { + currentIndex = index; + } + + width: 50*model.count + spacing*(model.count-1); height: 50 + orientation: ListView.Horizontal + model: NotesModel {} + delegate: notesDelegate + keyNavigationWraps: true + boundsBehavior: Flickable.StopAtBounds + + Component { + id: notesDelegate + + ToggleButton { + id: noteButton + + width: height; height: noteChooser.height + offImageSource: offSource + onImageSource: onSource + state: noteButton.ListView.isCurrentItem ? "pressed" : "unPressed" + onSelected: { + noteChooser.noteSelected(note, frequency, index) + if (note != "Auto") { + currentFrequency = frequency + } + } + onPushed: { + noteButton.ListView.view.currentIndex = index + } + } + } +} diff --git a/demos/mobile/guitartuner/src/mycomponents/NotesModel.qml b/demos/mobile/guitartuner/src/mycomponents/NotesModel.qml new file mode 100644 index 0000000..3d9c12a --- /dev/null +++ b/demos/mobile/guitartuner/src/mycomponents/NotesModel.qml @@ -0,0 +1,105 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 1.0 + +/* The model component for the NoteButtonView. */ +ListModel { + ListElement { + note: "E" + offSource: "./images/tuner_e.png" + onSource: "./images/tuner_e_on.png" + bigSource: "./mycomponents/images/big_e.png" + glowSource: "./mycomponents/images/glowing_e.png" + frequency: "82.407" + interval: "5" + } + ListElement { + note: "A" + offSource: "./images/tuner_a.png" + onSource: "./images/tuner_a_on.png" + bigSource: "./mycomponents/images/big_a.png" + glowSource: "./mycomponents/images/glowing_a.png" + frequency: "110.00" + interval: "5" + } + ListElement { + note: "D" + offSource: "./images/tuner_d.png" + onSource: "./images/tuner_d_on.png" + bigSource: "./mycomponents/images/big_d.png" + glowSource: "./mycomponents/images/glowing_d.png" + frequency: "146.83" + interval: "5" + } + ListElement { + note: "G" + offSource: "./images/tuner_g.png" + onSource: "./images/tuner_g_on.png" + bigSource: "./mycomponents/images/big_g.png" + glowSource: "./mycomponents/images/glowing_g.png" + frequency: "196.00" + interval: "4" + } + ListElement { + note: "B" + offSource: "./images/tuner_b.png" + onSource: "./images/tuner_b_on.png" + bigSource: "./mycomponents/images/big_b.png" + glowSource: "./mycomponents/images/glowing_b.png" + frequency: "246.94" + interval: "5" + } + ListElement { + note: "e" + offSource: "./images/tuner_e.png" + onSource: "./images/tuner_e_on.png" + bigSource: "./mycomponents/images/big_e.png" + glowSource: "./mycomponents/images/glowing_e.png" + frequency: "329.63" + interval: "9999" //Big enough that we can't move over this note + } + ListElement { + note: "Auto" + offSource: "./images/tuner_auto.png" + onSource: "./images/tuner_auto_on.png" + frequency: "82.407" + } +} diff --git a/demos/mobile/guitartuner/src/mycomponents/ToggleButton.qml b/demos/mobile/guitartuner/src/mycomponents/ToggleButton.qml new file mode 100644 index 0000000..cecf015 --- /dev/null +++ b/demos/mobile/guitartuner/src/mycomponents/ToggleButton.qml @@ -0,0 +1,110 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 1.0 + +/* A toggle button component. */ +Rectangle { + id: toggleButton + + property url offImageSource: "" + property url onImageSource: "" + property alias imageSource: buttonImage.source + + signal selected() + signal pushed() + + color: "transparent" + state: "unPressed" + onStateChanged: { + if (state == "pressed") { + selected() + } + } + + Image { + id: buttonImage + + smooth: true + anchors.fill: parent + } + MouseArea { + id: mouseArea + + anchors.fill: parent + onPressed: { + if (parent.state == "unPressed") { + pushed() + } + } + } + + states: [ + State { + name: "pressed" + PropertyChanges { + target: toggleButton + scale: 0.95 + imageSource: onImageSource + } + }, + State { + name: "unPressed" + PropertyChanges { + target: toggleButton + scale: 1/0.95 + imageSource: offImageSource + } + } + ] + + transitions: [ + Transition { + from: "unPressed" + to: "pressed" + reversible: true + PropertyAnimation { + target: toggleButton + properties: "scale" + duration: 100 + } + } + ] +} diff --git a/demos/mobile/guitartuner/src/mycomponents/adjustbars.js b/demos/mobile/guitartuner/src/mycomponents/adjustbars.js new file mode 100644 index 0000000..a96292d --- /dev/null +++ b/demos/mobile/guitartuner/src/mycomponents/adjustbars.js @@ -0,0 +1,89 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/* JavaScript functions for creating, handling and + * destroying the bars of the adjuster component. */ + +var maxBars = 10; +var firstBarHeight = 5; +var bars = new Array(maxBars); +var colors = new Array(maxBars); +var barWidthFactor = 2.3; + +function createBars() { + var barWidth = adjuster.width/maxBars/barWidthFactor; + for (var i = 1; i <= maxBars; i++) { + //Create, configure and store the bars. + var bar = Qt.createQmlObject('import QtQuick 1.0; Rectangle {smooth: true}', adjuster, "dynamicBar"); + bar.width = barWidth; + bar.height = firstBarHeight+(i/maxBars)*(adjuster.height*0.8-firstBarHeight); + bar.radius = bar.width/2; + bar.x = (i-1)*(barWidthFactor*barWidth); + bar.y = adjuster.height/2 - bar.height/2; + bars[i-1] = bar; + + //Calculate and store the colors + if (i < maxBars/2) { + colors[i-1] = Qt.rgba(1-i/(maxBars/2), 1, 1-i/(maxBars/2), i); + } + else { + colors[i-1] = Qt.rgba((i-(maxBars/2))/(maxBars/2), 1-((i-(maxBars/2))/(maxBars/2)), 0, i); + } + } +} + +function destroyBars() { + for (var i = 0; i < maxBars; i++) { + bars[i].color = "transparent" //Colors must be set to transparent or otherwise the bars will stay appeared. + bars[i].destroy(); + } +} + +function fillBars(barNumber) { + //Set the color for the bars (transparent from the selected bar to the end). + for (var i = 0; i < maxBars; i++) { + if (i < barNumber) { + bars[i].color = colors[i]; + } + else { + bars[i].color = "black"; + } + } +} diff --git a/demos/mobile/guitartuner/src/mycomponents/images/big_a.png b/demos/mobile/guitartuner/src/mycomponents/images/big_a.png Binary files differnew file mode 100644 index 0000000..3838e76 --- /dev/null +++ b/demos/mobile/guitartuner/src/mycomponents/images/big_a.png diff --git a/demos/mobile/guitartuner/src/mycomponents/images/big_b.png b/demos/mobile/guitartuner/src/mycomponents/images/big_b.png Binary files differnew file mode 100644 index 0000000..114b32d --- /dev/null +++ b/demos/mobile/guitartuner/src/mycomponents/images/big_b.png diff --git a/demos/mobile/guitartuner/src/mycomponents/images/big_d.png b/demos/mobile/guitartuner/src/mycomponents/images/big_d.png Binary files differnew file mode 100644 index 0000000..3ede9f0 --- /dev/null +++ b/demos/mobile/guitartuner/src/mycomponents/images/big_d.png diff --git a/demos/mobile/guitartuner/src/mycomponents/images/big_e.png b/demos/mobile/guitartuner/src/mycomponents/images/big_e.png Binary files differnew file mode 100644 index 0000000..cc1f488 --- /dev/null +++ b/demos/mobile/guitartuner/src/mycomponents/images/big_e.png diff --git a/demos/mobile/guitartuner/src/mycomponents/images/big_g.png b/demos/mobile/guitartuner/src/mycomponents/images/big_g.png Binary files differnew file mode 100644 index 0000000..804177b --- /dev/null +++ b/demos/mobile/guitartuner/src/mycomponents/images/big_g.png diff --git a/demos/mobile/guitartuner/src/mycomponents/images/glowing_a.png b/demos/mobile/guitartuner/src/mycomponents/images/glowing_a.png Binary files differnew file mode 100644 index 0000000..b6fd0e2 --- /dev/null +++ b/demos/mobile/guitartuner/src/mycomponents/images/glowing_a.png diff --git a/demos/mobile/guitartuner/src/mycomponents/images/glowing_b.png b/demos/mobile/guitartuner/src/mycomponents/images/glowing_b.png Binary files differnew file mode 100644 index 0000000..b5fa016 --- /dev/null +++ b/demos/mobile/guitartuner/src/mycomponents/images/glowing_b.png diff --git a/demos/mobile/guitartuner/src/mycomponents/images/glowing_d.png b/demos/mobile/guitartuner/src/mycomponents/images/glowing_d.png Binary files differnew file mode 100644 index 0000000..32f1a29 --- /dev/null +++ b/demos/mobile/guitartuner/src/mycomponents/images/glowing_d.png diff --git a/demos/mobile/guitartuner/src/mycomponents/images/glowing_e.png b/demos/mobile/guitartuner/src/mycomponents/images/glowing_e.png Binary files differnew file mode 100644 index 0000000..4be9f2a --- /dev/null +++ b/demos/mobile/guitartuner/src/mycomponents/images/glowing_e.png diff --git a/demos/mobile/guitartuner/src/mycomponents/images/glowing_g.png b/demos/mobile/guitartuner/src/mycomponents/images/glowing_g.png Binary files differnew file mode 100644 index 0000000..4216d82 --- /dev/null +++ b/demos/mobile/guitartuner/src/mycomponents/images/glowing_g.png diff --git a/demos/mobile/guitartuner/src/mycomponents/images/guitartuner_malli.png b/demos/mobile/guitartuner/src/mycomponents/images/guitartuner_malli.png Binary files differnew file mode 100644 index 0000000..dbe3fc7 --- /dev/null +++ b/demos/mobile/guitartuner/src/mycomponents/images/guitartuner_malli.png diff --git a/demos/mobile/guitartuner/src/mycomponents/images/guitartuner_skin.png b/demos/mobile/guitartuner/src/mycomponents/images/guitartuner_skin.png Binary files differnew file mode 100644 index 0000000..5d53df9 --- /dev/null +++ b/demos/mobile/guitartuner/src/mycomponents/images/guitartuner_skin.png diff --git a/demos/mobile/guitartuner/src/mycomponents/images/lcdFrame.png b/demos/mobile/guitartuner/src/mycomponents/images/lcdFrame.png Binary files differnew file mode 100644 index 0000000..ff8dffc --- /dev/null +++ b/demos/mobile/guitartuner/src/mycomponents/images/lcdFrame.png diff --git a/demos/mobile/guitartuner/src/mycomponents/images/meterBG.png b/demos/mobile/guitartuner/src/mycomponents/images/meterBG.png Binary files differnew file mode 100644 index 0000000..4046355 --- /dev/null +++ b/demos/mobile/guitartuner/src/mycomponents/images/meterBG.png diff --git a/demos/mobile/guitartuner/src/mycomponents/images/mute.png b/demos/mobile/guitartuner/src/mycomponents/images/mute.png Binary files differnew file mode 100644 index 0000000..382e6047 --- /dev/null +++ b/demos/mobile/guitartuner/src/mycomponents/images/mute.png diff --git a/demos/mobile/guitartuner/src/mycomponents/images/pointer.png b/demos/mobile/guitartuner/src/mycomponents/images/pointer.png Binary files differnew file mode 100644 index 0000000..d0cb21b --- /dev/null +++ b/demos/mobile/guitartuner/src/mycomponents/images/pointer.png diff --git a/demos/mobile/guitartuner/src/mycomponents/images/pointerShadow.png b/demos/mobile/guitartuner/src/mycomponents/images/pointerShadow.png Binary files differnew file mode 100644 index 0000000..a708639 --- /dev/null +++ b/demos/mobile/guitartuner/src/mycomponents/images/pointerShadow.png diff --git a/demos/mobile/guitartuner/src/mycomponents/images/power.png b/demos/mobile/guitartuner/src/mycomponents/images/power.png Binary files differnew file mode 100644 index 0000000..8ec0c5c --- /dev/null +++ b/demos/mobile/guitartuner/src/mycomponents/images/power.png diff --git a/demos/mobile/guitartuner/src/mycomponents/images/quit.png b/demos/mobile/guitartuner/src/mycomponents/images/quit.png Binary files differnew file mode 100644 index 0000000..2a9443e --- /dev/null +++ b/demos/mobile/guitartuner/src/mycomponents/images/quit.png diff --git a/demos/mobile/guitartuner/src/mycomponents/images/sensitivity.png b/demos/mobile/guitartuner/src/mycomponents/images/sensitivity.png Binary files differnew file mode 100644 index 0000000..c3d2ea3 --- /dev/null +++ b/demos/mobile/guitartuner/src/mycomponents/images/sensitivity.png diff --git a/demos/mobile/guitartuner/src/mycomponents/images/tuner_a.png b/demos/mobile/guitartuner/src/mycomponents/images/tuner_a.png Binary files differnew file mode 100644 index 0000000..a1823e5 --- /dev/null +++ b/demos/mobile/guitartuner/src/mycomponents/images/tuner_a.png diff --git a/demos/mobile/guitartuner/src/mycomponents/images/tuner_a_on.png b/demos/mobile/guitartuner/src/mycomponents/images/tuner_a_on.png Binary files differnew file mode 100644 index 0000000..7c78cbd --- /dev/null +++ b/demos/mobile/guitartuner/src/mycomponents/images/tuner_a_on.png diff --git a/demos/mobile/guitartuner/src/mycomponents/images/tuner_auto.png b/demos/mobile/guitartuner/src/mycomponents/images/tuner_auto.png Binary files differnew file mode 100644 index 0000000..b9e494b --- /dev/null +++ b/demos/mobile/guitartuner/src/mycomponents/images/tuner_auto.png diff --git a/demos/mobile/guitartuner/src/mycomponents/images/tuner_auto_on.png b/demos/mobile/guitartuner/src/mycomponents/images/tuner_auto_on.png Binary files differnew file mode 100644 index 0000000..d5608d8 --- /dev/null +++ b/demos/mobile/guitartuner/src/mycomponents/images/tuner_auto_on.png diff --git a/demos/mobile/guitartuner/src/mycomponents/images/tuner_b.png b/demos/mobile/guitartuner/src/mycomponents/images/tuner_b.png Binary files differnew file mode 100644 index 0000000..94977f8 --- /dev/null +++ b/demos/mobile/guitartuner/src/mycomponents/images/tuner_b.png diff --git a/demos/mobile/guitartuner/src/mycomponents/images/tuner_b_on.png b/demos/mobile/guitartuner/src/mycomponents/images/tuner_b_on.png Binary files differnew file mode 100644 index 0000000..78841dc --- /dev/null +++ b/demos/mobile/guitartuner/src/mycomponents/images/tuner_b_on.png diff --git a/demos/mobile/guitartuner/src/mycomponents/images/tuner_d.png b/demos/mobile/guitartuner/src/mycomponents/images/tuner_d.png Binary files differnew file mode 100644 index 0000000..293ee55 --- /dev/null +++ b/demos/mobile/guitartuner/src/mycomponents/images/tuner_d.png diff --git a/demos/mobile/guitartuner/src/mycomponents/images/tuner_d_on.png b/demos/mobile/guitartuner/src/mycomponents/images/tuner_d_on.png Binary files differnew file mode 100644 index 0000000..705de41 --- /dev/null +++ b/demos/mobile/guitartuner/src/mycomponents/images/tuner_d_on.png diff --git a/demos/mobile/guitartuner/src/mycomponents/images/tuner_e.png b/demos/mobile/guitartuner/src/mycomponents/images/tuner_e.png Binary files differnew file mode 100644 index 0000000..569d2c6 --- /dev/null +++ b/demos/mobile/guitartuner/src/mycomponents/images/tuner_e.png diff --git a/demos/mobile/guitartuner/src/mycomponents/images/tuner_e_on.png b/demos/mobile/guitartuner/src/mycomponents/images/tuner_e_on.png Binary files differnew file mode 100644 index 0000000..1342a91 --- /dev/null +++ b/demos/mobile/guitartuner/src/mycomponents/images/tuner_e_on.png diff --git a/demos/mobile/guitartuner/src/mycomponents/images/tuner_g.png b/demos/mobile/guitartuner/src/mycomponents/images/tuner_g.png Binary files differnew file mode 100644 index 0000000..a8f0de5 --- /dev/null +++ b/demos/mobile/guitartuner/src/mycomponents/images/tuner_g.png diff --git a/demos/mobile/guitartuner/src/mycomponents/images/tuner_g_on.png b/demos/mobile/guitartuner/src/mycomponents/images/tuner_g_on.png Binary files differnew file mode 100644 index 0000000..6fdca41 --- /dev/null +++ b/demos/mobile/guitartuner/src/mycomponents/images/tuner_g_on.png diff --git a/demos/mobile/guitartuner/src/mycomponents/images/voicemode_off.png b/demos/mobile/guitartuner/src/mycomponents/images/voicemode_off.png Binary files differnew file mode 100644 index 0000000..0701dd3 --- /dev/null +++ b/demos/mobile/guitartuner/src/mycomponents/images/voicemode_off.png diff --git a/demos/mobile/guitartuner/src/mycomponents/images/voicemode_on.png b/demos/mobile/guitartuner/src/mycomponents/images/voicemode_on.png Binary files differnew file mode 100644 index 0000000..986d589 --- /dev/null +++ b/demos/mobile/guitartuner/src/mycomponents/images/voicemode_on.png diff --git a/demos/mobile/guitartuner/src/mycomponents/images/volume.png b/demos/mobile/guitartuner/src/mycomponents/images/volume.png Binary files differnew file mode 100644 index 0000000..46fdb7f --- /dev/null +++ b/demos/mobile/guitartuner/src/mycomponents/images/volume.png diff --git a/demos/mobile/guitartuner/src/mycomponents/images/volume_off.png b/demos/mobile/guitartuner/src/mycomponents/images/volume_off.png Binary files differnew file mode 100644 index 0000000..a97e422 --- /dev/null +++ b/demos/mobile/guitartuner/src/mycomponents/images/volume_off.png diff --git a/demos/mobile/guitartuner/src/voiceanalyzer.cpp b/demos/mobile/guitartuner/src/voiceanalyzer.cpp new file mode 100644 index 0000000..9990e6d --- /dev/null +++ b/demos/mobile/guitartuner/src/voiceanalyzer.cpp @@ -0,0 +1,295 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "voiceanalyzer.h" + +/** + * Constant used to scale the cut-off density for the fft helper. + */ +const static float CutOffScaler = 0.05; + +/** + * Force the precision to be "1/PrecisionPerNote" notes + * near the target frequency. + */ +const static int PrecisionPerNote = 4; + +/** + * TargetFrequencyParameter is a constant which implies the index at + * which corresponds to the target frequency. + * 0.5 * N * 1/TargetFrequencyParameter is (about) the index which + * corresponds to the given target frequency. + * Effectively TargetFrequencyParameter = 2^z, and the z*TargetFrequency + * is the maximum frequency that can be noticed. + */ +const static int TargetFrequencyParameter = 4; + + +VoiceAnalyzer::VoiceAnalyzer(const QAudioFormat &format, QObject *parent): + QIODevice(parent), + m_format(format), + m_frequency(0), + m_position(0), + m_fftHelper(new FastFourierTransformer(this)) +{ + Q_ASSERT(qFuzzyCompare(M_SAMPLE_COUNT_MULTIPLIER, + float(2)/(M_TWELTH_ROOT_OF_2 -1.0))); + m_totalSampleCount = qRound(qreal(PrecisionPerNote) + *TargetFrequencyParameter + *M_SAMPLE_COUNT_MULTIPLIER); + m_samples.reserve(m_totalSampleCount); + int i = 2; + int j = 1; + for (; i < TargetFrequencyParameter; i *= 2) { + j++; + } + m_maximumVoiceDifference = j*12; + + setCutOffPercentage(CutOffScaler); +} + +/** + * Opens the parent QIODevice. Sets up the analysation parameters. + */ +void VoiceAnalyzer::start(qreal frequency) +{ + m_stepSize = (qreal) 1.0 * m_format.sampleRate() + / (TargetFrequencyParameter*2*frequency); + m_frequency = frequency; + open(QIODevice::WriteOnly); +} + +/** + * Closes the parent QIODevice, thus the voice is not analysed anymore. + * Resets the m_samples QList. + */ +void VoiceAnalyzer::stop() +{ + m_samples.clear(); + m_samples.reserve(m_totalSampleCount); + close(); +} + +/** + * Called when data is obtained. Stores each m_stepSize sample + * into a QList to be analysed. + */ +qint64 VoiceAnalyzer::writeData(const char *data, qint64 maxlen) +{ + const int channelBytes = m_format.sampleSize() / 8; + int sampleSize = m_format.channels() * channelBytes; + int m_stepSizeInBytes = m_stepSize*sampleSize; + // assert that each sample fits fully into the data + Q_ASSERT((m_position % sampleSize)==0); + const uchar *ptr = reinterpret_cast<const uchar *>(data); + while (m_position < maxlen) { + if (m_samples.size() < m_totalSampleCount) { + m_samples.append(getValueInt16(ptr+m_position)); + } + else { + analyzeVoice(); + m_samples.clear(); + m_samples.reserve(m_totalSampleCount); + // fast forward position to the first position after maxlen or to the maxlen + m_position += ((m_stepSizeInBytes - 1 + maxlen - m_position) / + m_stepSizeInBytes) * m_stepSizeInBytes; + break; + } + m_position += m_stepSizeInBytes; + } + m_position -= maxlen; + return maxlen; +} + +/** + * Interprets ptr as a pointer to int value and returns it. + */ +qint16 VoiceAnalyzer::getValueInt16(const uchar *ptr) +{ + qint16 realValue = 0; + if (m_format.sampleSize() == 8) + { + const qint16 value = *reinterpret_cast<const quint8*>(ptr); + if (m_format.sampleType() == QAudioFormat::UnSignedInt) { + realValue = value - M_MAX_AMPLITUDE_8BIT_SIGNED - 1; + } else if (m_format.sampleType() == QAudioFormat::SignedInt) { + realValue = value; + } + } else if (m_format.sampleSize() == 16) { + qint16 value = 0; + if (m_format.byteOrder() == QAudioFormat::LittleEndian) + value = qFromLittleEndian<quint16>(ptr); + else + value = qFromBigEndian<quint16>(ptr); + + if (m_format.sampleType() == QAudioFormat::UnSignedInt) { + realValue = value - M_MAX_AMPLITUDE_16BIT_SIGNED; + } else if (m_format.sampleType() == QAudioFormat::SignedInt) { + realValue = value; + } + } + return realValue; +} + +/** + * Takes a number between 0 and 1, scales it with CutOffScaler, + * multiplies it with maximum density, and then gives it + * to the fft helper. + */ +void VoiceAnalyzer::setCutOffPercentage(qreal cutoff) +{ + cutoff = CutOffScaler*cutoff; + if (m_format.sampleSize() == 8) { + float t = cutoff*m_totalSampleCount*M_MAX_AMPLITUDE_8BIT_SIGNED; + m_fftHelper->setCutOffForDensity(t); + } + else if (m_format.sampleSize() == 16) { + float t = cutoff*m_totalSampleCount*M_MAX_AMPLITUDE_16BIT_SIGNED; + m_fftHelper->setCutOffForDensity(t); + } +} + +/** + * Returns the current target frequency. + */ +qreal VoiceAnalyzer::frequency() +{ + return m_frequency; +} + +/** + * Returns the maximum absolute value sent by + * the voiceDifference() signal. + */ +int VoiceAnalyzer::getMaximumVoiceDifference() +{ + return m_maximumVoiceDifference; +} + +/** + * Returns the maximum precision per note + * near the target frequency. + */ +int VoiceAnalyzer::getMaximumPrecisionPerNote() +{ + return PrecisionPerNote; +} + +/** + * Analyzes the voice frequency and emits appropriate signals. + */ +void VoiceAnalyzer::analyzeVoice() +{ + m_fftHelper->calculateFFT(m_samples); + int index = m_fftHelper->getMaximumDensityIndex(); + + // If index == -1 + if (index == -1) { + // The voice is to be filtered away. + // Emit the lowVoice signal and return. + emit lowVoice(); + qDebug() << "low voice"; + return; + } + // Else, continue + + // Let the correctIndex to be + // the nearest index corresponding to the correct frequency. + qreal stepSizeInFrequency = (qreal)m_format.sampleRate() + / (m_totalSampleCount * m_stepSize); + qreal newFrequency = qreal(index) * stepSizeInFrequency; + // Calculate the nearest index corresponding to the correct frequency. + int correctIndex = qRound(m_frequency / stepSizeInFrequency); + qreal value = 0; + + // If the obtained frequency is more than + // log_2(TargetFrequencyParameter) octaves less than the m_frequency: + + // Note: + // Instead of m_frequency/TargetFrequencyParameter > newFrequency, + // the comparison is done without a div instructions by + // m_frequency > newFrequency * TargetFrequencyParameter. + + if (m_frequency > newFrequency * TargetFrequencyParameter) { + // Set the difference value to be -m_maximumVoiceDifference. + qDebug() << "compare" << "low" << newFrequency << m_frequency - stepSizeInFrequency * correctIndex << (m_frequency - stepSizeInFrequency * correctIndex) / stepSizeInFrequency; + value = -m_maximumVoiceDifference; + } + // Else, if the obtained frequency is more than + // log_2(TargetFrequencyParameter) octaves more than the m_frequency: + else if (m_frequency*TargetFrequencyParameter < newFrequency) { + // Set the difference value to be m_maximumVoiceDifference. + qDebug() << "compare" << "high" << newFrequency << m_frequency - stepSizeInFrequency * correctIndex << (m_frequency - stepSizeInFrequency * correctIndex) / stepSizeInFrequency; + value = m_maximumVoiceDifference; + } + // Else: + else { + // Calculate the difference between the obtained and the correct + // frequency in tones. + // Use stepSizeInFrequency * correctIndex instead of + // m_frequency so that the value is zero when there is correct + // voice obtained. Set the difference value to be + // log(frequency / target frequency) * 12 / log(2). + value = log(newFrequency / (stepSizeInFrequency * correctIndex)) + * 12 / M_LN2; + qDebug() << "compare" << value << newFrequency << m_frequency - stepSizeInFrequency * correctIndex << (m_frequency - stepSizeInFrequency * correctIndex) / stepSizeInFrequency; + } + + // Emit voiceDifference signal. + QVariant valueVar(value); //Has to be QVariant for QML + emit voiceDifference(valueVar); + + // If the correctIndex is index, emit the correctFrequency signal. + if (correctIndex == index) { + emit(correctFrequency()); + } +} + +/** + * Empty implementation for readData, since no data is provided + * by the VoiceAnalyzer class. + */ +qint64 VoiceAnalyzer::readData(char *data, qint64 maxlen) +{ + Q_UNUSED(data); + Q_UNUSED(maxlen); + + return 0; +} diff --git a/demos/mobile/guitartuner/src/voiceanalyzer.h b/demos/mobile/guitartuner/src/voiceanalyzer.h new file mode 100644 index 0000000..147a0d6 --- /dev/null +++ b/demos/mobile/guitartuner/src/voiceanalyzer.h @@ -0,0 +1,93 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef VOICEANALYZER_H +#define VOICEANALYZER_H + +#include <QObject> +#include <QAudioFormat> +#include <QDebug> +#include <QtCore/qmath.h> +#include <QtCore/qendian.h> +#include <QVariant> + +#include "constants.h" +#include "fastfouriertransformer.h" +#include "math.h" + +class VoiceAnalyzer : public QIODevice +{ + Q_OBJECT +public: + VoiceAnalyzer(const QAudioFormat &format, QObject *parent = 0); + qint64 readData(char *data, qint64 maxlen); + qint64 writeData(const char *data, qint64 maxlen); + void start(qreal frequency); + void stop(); + qreal frequency(); + int getMaximumVoiceDifference(); + int getMaximumPrecisionPerNote(); + +public slots: + void setCutOffPercentage(qreal cutoff); + +private: + const QAudioFormat m_format; + QList<qint16> m_samples; + int m_totalSampleCount; + int m_maximumVoiceDifference; + + qint16 getValueInt16(const uchar *ptr); + int m_stepSize; + qreal m_frequency; + qint64 m_position; + FastFourierTransformer *m_fftHelper; + void analyzeVoice(); +signals: + void voiceDifference(QVariant frequency); + void correctFrequency(); + void lowVoice(); + +public slots: + +}; + + +#endif // VOICEANALYZER_H diff --git a/demos/mobile/guitartuner/src/voicegenerator.cpp b/demos/mobile/guitartuner/src/voicegenerator.cpp new file mode 100644 index 0000000..ce25b6e --- /dev/null +++ b/demos/mobile/guitartuner/src/voicegenerator.cpp @@ -0,0 +1,246 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "voicegenerator.h" + +const int BufferSizeMilliseconds = 100; + +VoiceGenerator::VoiceGenerator(const QAudioFormat &format, + qreal frequency, qreal amplitude, + QObject *parent) : + QIODevice(parent), + m_format(format), + m_amplitude(0.5) +{ + Q_ASSERT(m_format.sampleSize() % 8 == 0); + int sampleBytes = m_format.channels() * (m_format.sampleSize() / 8); + // + 1 to round up, just to be sure that all samples fit. + qint64 samplesInBuffer = m_format.sampleRate() + * BufferSizeMilliseconds / 1000 + 1; + qint64 length = samplesInBuffer * sampleBytes; + m_buffer.resize(length); + m_max_position = 0; + m_position = 0; + m_amplitude = amplitude; + setFrequency(frequency); +} + +VoiceGenerator::~VoiceGenerator() +{ +} + +/** + * Opens the parent QIODevice. + */ +void VoiceGenerator::start() +{ + open(QIODevice::ReadOnly); +} + +/** + * Closes the parent QIODevice. Resets the m_position to zero. + */ +void VoiceGenerator::stop() +{ + close(); + m_position = 0; +} + +/** + * Sets the frequency to new frequency. + */ +void VoiceGenerator::setFrequency(qreal frequency) +{ + Q_ASSERT(1 / frequency < BufferSizeMilliseconds); + this->m_frequency = frequency; + refreshData(); +} + +/** + * Sets the amplitude for the voice. + */ +void VoiceGenerator::setAmplitude(qreal amplitude) +{ + Q_ASSERT(amplitude >= 0); + m_amplitude = amplitude; + refreshData(); +} + +/** + * Returns the current frequency. + */ +qreal VoiceGenerator::frequency() +{ + return m_frequency; +} + +/** + * Generates voice data corresponding a sine voice with target frequency. + * The number of data generated is calculated + * and stored to m_max_position. + */ +void VoiceGenerator::refreshData() +{ + const int channelBytes = m_format.sampleSize() / 8; + const int sampleSize = m_format.channels() * channelBytes; + const qint64 voiceOscillationsInBuffer = BufferSizeMilliseconds + * m_frequency / 1000; + const qint64 voiceSamplesInBuffer = voiceOscillationsInBuffer + * m_format.sampleRate() / m_frequency; + m_max_position = voiceSamplesInBuffer * sampleSize; + qint64 dataGenerationLength = m_buffer.size(); + + + Q_ASSERT(m_max_position % (sampleSize) == 0); + Q_ASSERT(dataGenerationLength <= m_buffer.size()); + + short *t = (short*)m_buffer.data(); + + +/* + int te ; + static float fpos = 0.0f; + //dataGenerationLength>>=1; // in words + for (int f=0; f<dataGenerationLength; f++) { + te = (short)((sinf(fpos))* (65536.0f/2.0f)); + fpos += m_frequency/2000.0f; + t[f]= te; + }; + + m_amplitude = 1.0f; */ + uchar *ptr = reinterpret_cast<uchar *>(m_buffer.data()); + int sampleIndex = 0; + while (dataGenerationLength > 0) { + qreal realValue = 0; + if (sampleIndex < voiceSamplesInBuffer) { + realValue = m_amplitude + *qSin(2.0f * M_PI * m_frequency + * qreal(sampleIndex % m_format.sampleRate()) + / m_format.sampleRate()); + } + for (int i=0; i<m_format.channels(); ++i) { + setValue(ptr, realValue); + ptr += channelBytes; + dataGenerationLength -= channelBytes; + } + ++sampleIndex; + } +} + +/** + * Stores the realValue into bytes pointed by ptr as an int value. + * Align-safe. + */ +void VoiceGenerator::setValue(uchar *ptr, qreal realValue) { + if (m_format.sampleSize() == 8) + { + quint8 value = 0; + if (m_format.sampleType() == QAudioFormat::UnSignedInt) { + value = static_cast<quint8>( + qRound((1.0 + realValue) / 2 + * M_MAX_AMPLITUDE_8BIT_UNSIGNED)); + } else if (m_format.sampleType() == QAudioFormat::SignedInt) { + value = static_cast<qint8>( + qRound(realValue + * M_MAX_AMPLITUDE_8BIT_SIGNED)); + } + *reinterpret_cast<quint8*>(ptr) = value; + } else if (m_format.sampleSize() == 16) { + quint16 value = 0; + if (m_format.sampleType() == QAudioFormat::UnSignedInt) { + value = static_cast<quint16>( + qRound((1.0 + realValue) / 2 + * M_MAX_AMPLITUDE_16BIT_UNSIGNED)); + } else if (m_format.sampleType() == QAudioFormat::SignedInt) { + value = static_cast<qint16>( + qRound(realValue + * M_MAX_AMPLITUDE_16BIT_SIGNED)); + } + if (m_format.byteOrder() == QAudioFormat::LittleEndian) + qToLittleEndian<qint16>(value, ptr); + else + qToBigEndian<qint16>(value, ptr); + } +} + +qint64 VoiceGenerator::bytesAvailable() const +{ + return m_max_position + QIODevice::bytesAvailable(); +} + +/** + * Called by the QIODevice. Puts maxlen amount of voice + * samples into the data array. + */ +qint64 VoiceGenerator::readData(char *data, qint64 maxlen) +{ + qint64 total = 0; + qint64 chunk = 0; + while (total < maxlen) { + if (maxlen - total >= m_max_position - m_position) { + // the needed buffer is longer than the currently + // available buffer from m_position to the m_max_position + chunk = m_max_position - m_position; + memcpy(data, m_buffer.constData() + m_position, chunk); + m_position = 0; + } + else { + // we can copy the needed data directly, and the loop will end + chunk = maxlen - total; + memcpy(data, m_buffer.constData() + m_position, chunk); + m_position = (m_position + chunk) % m_max_position; + } + data += chunk; + total += chunk; + } + return total; +} + +/** + * Empty implementation for writeData, since no data is provided + * for the VoiceGenerator class. + */ +qint64 VoiceGenerator::writeData(const char *data, qint64 maxlen) +{ + Q_UNUSED(data); + Q_UNUSED(maxlen); + + return 0; +} diff --git a/demos/mobile/guitartuner/src/voicegenerator.h b/demos/mobile/guitartuner/src/voicegenerator.h new file mode 100644 index 0000000..e4abd90 --- /dev/null +++ b/demos/mobile/guitartuner/src/voicegenerator.h @@ -0,0 +1,86 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef VOICEGENERATOR_H +#define VOICEGENERATOR_H + +#include <QIODevice> +#include <QByteArray> +#include <QAudioFormat> +#include <QtCore/qmath.h> +#include <QtCore/qendian.h> +#include <QDebug> + +#include "constants.h" + + +class VoiceGenerator : public QIODevice +{ + Q_OBJECT +public: + VoiceGenerator(const QAudioFormat &format, qreal frequency, qreal amplitude, QObject *parent = 0); + ~VoiceGenerator(); + void setFrequency(qreal frequency); + qint64 readData(char *data, qint64 maxlen); + qint64 writeData(const char *data, qint64 maxlen); + qint64 bytesAvailable() const; + qreal frequency(); +signals: + +public slots: + void setAmplitude(qreal amplitude); + void start(); + void stop(); + +private: + void setValue(uchar *ptr, qreal realValue); + void refreshData(); + const QAudioFormat m_format; + // buffer to store the data + QByteArray m_buffer; + // current position in buffer + qint64 m_position; + // max position depends on the sample rate of format and the frequency of voice + qint64 m_max_position; + qreal m_amplitude; + qreal m_frequency; +}; + +#endif // VOICEGENERATOR_H diff --git a/demos/mobile/guitartuner/ui_guitartunerui.h b/demos/mobile/guitartuner/ui_guitartunerui.h new file mode 100644 index 0000000..3a698aa --- /dev/null +++ b/demos/mobile/guitartuner/ui_guitartunerui.h @@ -0,0 +1,181 @@ +/******************************************************************************** +** Form generated from reading UI file 'guitartunerui.ui' +** +** Created: Wed Mar 2 14:59:33 2011 +** by: Qt User Interface Compiler version 4.7.2 +** +** WARNING! All changes made in this file will be lost when recompiling UI file! +********************************************************************************/ + +#ifndef UI_GUITARTUNERUI_H +#define UI_GUITARTUNERUI_H + +#include <QtCore/QVariant> +#include <QtGui/QAction> +#include <QtGui/QApplication> +#include <QtGui/QButtonGroup> +#include <QtGui/QFrame> +#include <QtGui/QHBoxLayout> +#include <QtGui/QHeaderView> +#include <QtGui/QLabel> +#include <QtGui/QPushButton> +#include <QtGui/QSlider> +#include <QtGui/QToolButton> +#include <QtGui/QVBoxLayout> +#include <QtGui/QWidget> + +QT_BEGIN_NAMESPACE + +class Ui_GuitarTunerUI +{ +public: + QVBoxLayout *verticalLayout_2; + QLabel *tabulatorIcon; + QSlider *correctSoundSlider; + QHBoxLayout *horizontalLayout; + QToolButton *buttonPrev; + QLabel *noteLabel; + QToolButton *buttonNext; + QPushButton *modeButton; + QFrame *line; + QHBoxLayout *horizontalLayout_2; + QSlider *soundSlider; + QToolButton *soundButton; + QLabel *micSensitivityLabel; + + void setupUi(QWidget *GuitarTunerUI) + { + if (GuitarTunerUI->objectName().isEmpty()) + GuitarTunerUI->setObjectName(QString::fromUtf8("GuitarTunerUI")); + GuitarTunerUI->resize(187, 279); + verticalLayout_2 = new QVBoxLayout(GuitarTunerUI); + verticalLayout_2->setSpacing(6); + verticalLayout_2->setContentsMargins(11, 11, 11, 11); + verticalLayout_2->setObjectName(QString::fromUtf8("verticalLayout_2")); + tabulatorIcon = new QLabel(GuitarTunerUI); + tabulatorIcon->setObjectName(QString::fromUtf8("tabulatorIcon")); + tabulatorIcon->setText(QString::fromUtf8("")); + tabulatorIcon->setPixmap(QPixmap(QString::fromUtf8(":/images/guitartab.svg"))); + tabulatorIcon->setAlignment(Qt::AlignCenter); + + verticalLayout_2->addWidget(tabulatorIcon); + + correctSoundSlider = new QSlider(GuitarTunerUI); + correctSoundSlider->setObjectName(QString::fromUtf8("correctSoundSlider")); + correctSoundSlider->setEnabled(false); + correctSoundSlider->setAutoFillBackground(false); + correctSoundSlider->setMinimum(-50); + correctSoundSlider->setMaximum(50); + correctSoundSlider->setOrientation(Qt::Horizontal); + correctSoundSlider->setTickPosition(QSlider::TicksAbove); + correctSoundSlider->setTickInterval(50); + + verticalLayout_2->addWidget(correctSoundSlider); + + horizontalLayout = new QHBoxLayout(); + horizontalLayout->setSpacing(6); + horizontalLayout->setObjectName(QString::fromUtf8("horizontalLayout")); + buttonPrev = new QToolButton(GuitarTunerUI); + buttonPrev->setObjectName(QString::fromUtf8("buttonPrev")); + QSizePolicy sizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed); + sizePolicy.setHorizontalStretch(0); + sizePolicy.setVerticalStretch(0); + sizePolicy.setHeightForWidth(buttonPrev->sizePolicy().hasHeightForWidth()); + buttonPrev->setSizePolicy(sizePolicy); + buttonPrev->setArrowType(Qt::LeftArrow); + + horizontalLayout->addWidget(buttonPrev); + + noteLabel = new QLabel(GuitarTunerUI); + noteLabel->setObjectName(QString::fromUtf8("noteLabel")); + noteLabel->setAlignment(Qt::AlignCenter); + + horizontalLayout->addWidget(noteLabel); + + buttonNext = new QToolButton(GuitarTunerUI); + buttonNext->setObjectName(QString::fromUtf8("buttonNext")); + sizePolicy.setHeightForWidth(buttonNext->sizePolicy().hasHeightForWidth()); + buttonNext->setSizePolicy(sizePolicy); + buttonNext->setAutoRaise(false); + buttonNext->setArrowType(Qt::RightArrow); + + horizontalLayout->addWidget(buttonNext); + + + verticalLayout_2->addLayout(horizontalLayout); + + modeButton = new QPushButton(GuitarTunerUI); + modeButton->setObjectName(QString::fromUtf8("modeButton")); + + verticalLayout_2->addWidget(modeButton); + + line = new QFrame(GuitarTunerUI); + line->setObjectName(QString::fromUtf8("line")); + line->setFrameShape(QFrame::HLine); + line->setFrameShadow(QFrame::Sunken); + + verticalLayout_2->addWidget(line); + + horizontalLayout_2 = new QHBoxLayout(); + horizontalLayout_2->setSpacing(6); + horizontalLayout_2->setObjectName(QString::fromUtf8("horizontalLayout_2")); + soundSlider = new QSlider(GuitarTunerUI); + soundSlider->setObjectName(QString::fromUtf8("soundSlider")); + soundSlider->setValue(65); + soundSlider->setOrientation(Qt::Vertical); + + horizontalLayout_2->addWidget(soundSlider); + + soundButton = new QToolButton(GuitarTunerUI); + soundButton->setObjectName(QString::fromUtf8("soundButton")); + QIcon icon; + icon.addFile(QString::fromUtf8(":/images/note.svg"), QSize(), QIcon::Normal, QIcon::Off); + icon.addFile(QString::fromUtf8(":/images/noteNo.svg"), QSize(), QIcon::Normal, QIcon::On); + icon.addFile(QString::fromUtf8(":/images/noteNo.svg"), QSize(), QIcon::Active, QIcon::On); + soundButton->setIcon(icon); + soundButton->setIconSize(QSize(30, 30)); + soundButton->setCheckable(true); + soundButton->setAutoRaise(true); + + horizontalLayout_2->addWidget(soundButton); + + micSensitivityLabel = new QLabel(GuitarTunerUI); + micSensitivityLabel->setObjectName(QString::fromUtf8("micSensitivityLabel")); + QSizePolicy sizePolicy1(QSizePolicy::Fixed, QSizePolicy::Preferred); + sizePolicy1.setHorizontalStretch(0); + sizePolicy1.setVerticalStretch(0); + sizePolicy1.setHeightForWidth(micSensitivityLabel->sizePolicy().hasHeightForWidth()); + micSensitivityLabel->setSizePolicy(sizePolicy1); + + horizontalLayout_2->addWidget(micSensitivityLabel); + + + verticalLayout_2->addLayout(horizontalLayout_2); + + + retranslateUi(GuitarTunerUI); + + QMetaObject::connectSlotsByName(GuitarTunerUI); + } // setupUi + + void retranslateUi(QWidget *GuitarTunerUI) + { + GuitarTunerUI->setWindowTitle(QApplication::translate("GuitarTunerUI", "GuitarTunerUI", 0, QApplication::UnicodeUTF8)); + buttonPrev->setText(QApplication::translate("GuitarTunerUI", "...", 0, QApplication::UnicodeUTF8)); + noteLabel->setText(QApplication::translate("GuitarTunerUI", "A", 0, QApplication::UnicodeUTF8)); + buttonNext->setText(QApplication::translate("GuitarTunerUI", "...", 0, QApplication::UnicodeUTF8)); + modeButton->setText(QApplication::translate("GuitarTunerUI", "Change mode", 0, QApplication::UnicodeUTF8)); + soundButton->setText(QApplication::translate("GuitarTunerUI", "...", 0, QApplication::UnicodeUTF8)); + micSensitivityLabel->setText(QApplication::translate("GuitarTunerUI", "microphone\n" +"sensitivity", 0, QApplication::UnicodeUTF8)); + } // retranslateUi + +}; + +namespace Ui { + class GuitarTunerUI: public Ui_GuitarTunerUI {}; +} // namespace Ui + +QT_END_NAMESPACE + +#endif // UI_GUITARTUNERUI_H diff --git a/demos/mobile/quickhit/Button.qml b/demos/mobile/quickhit/Button.qml new file mode 100644 index 0000000..05ad78d --- /dev/null +++ b/demos/mobile/quickhit/Button.qml @@ -0,0 +1,86 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 1.0 + +Item { + width: 30 + height: 30 + smooth: true + + property string buttonPath // for example "qrc:/gfx/exit.png" + property int buttonId: 0 + + signal btnClicked(int buttonId) + + property bool animationEnabled: true + + Image { + id: image + anchors.fill: parent + source: buttonPath + fillMode: Image.PreserveAspectFit + smooth: true + } + + SequentialAnimation { + id:anim + PropertyAction { target: image; property: "scale"; value:"0.7"} + PauseAnimation { duration: 200 } + PropertyAction { target: image; property: "scale"; value:"1.0"} + } + + Timer { + id: buttonPressedTimer + interval: 300; running: false; repeat: false + onTriggered: btnClicked(buttonId) + } + + MouseArea { + anchors.fill: parent + onPressed: { + if (animationEnabled && !anim.running) { + anim.restart() + } + buttonPressedTimer.restart() + } + } + +} diff --git a/demos/mobile/quickhit/Game.js b/demos/mobile/quickhit/Game.js new file mode 100644 index 0000000..40db422 --- /dev/null +++ b/demos/mobile/quickhit/Game.js @@ -0,0 +1,180 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ + +var levelPlugin = null + +// --------------------------------------------------------------------------- +// hideMissiles +function hideMissiles() { + missile_1.stop() + missile_1.opacity = 0; + + missile_2.stop() + missile_2.opacity = 0; + + missile_3.stop() + missile_3.opacity = 0; + + missile_4.stop() + missile_4.opacity = 0; + + missile_5.stop() + missile_5.opacity = 0; + + enemy_missile_1.opacity = 0; + enemy_missile_2.opacity = 0; +} + +// --------------------------------------------------------------------------- +// GameOver +function gameOver() { + + // Stop GameEngine timers + GameEngine.enableEngineTimer(false) + + // Delete loaded plugin level + deleteLevel() + + // Hiding + myShip.opacity = 0 + btnPause.opacity = 0 +} + +// --------------------------------------------------------------------------- +// Pause game +function pauseGame(doPause) { + missile_1.pause(doPause) + missile_2.pause(doPause) + missile_3.pause(doPause) + missile_4.pause(doPause) + missile_5.pause(doPause) + enemy_missile_1.pause(doPause) + enemy_missile_2.pause(doPause) + + if (doPause) { + btnPause.opacity = 0 + } else { + btnPause.opacity = 1 + } + + GameEngine.pauseLevel(doPause) +} + +// --------------------------------------------------------------------------- +// Fire your missile +function fireMissile(aXpox, aFromYpos, aToYpos) { + if (missile_1.opacity<1) { + missile_1.fire(aXpox,aFromYpos,aToYpos) + } + else if (missile_2.opacity<1) { + missile_2.fire(aXpox,aFromYpos,aToYpos) + } + else if (missile_3.opacity<1) { + missile_3.fire(aXpox,aFromYpos,aToYpos) + } + else if (missile_4.opacity<1) { + missile_4.fire(aXpox,aFromYpos,aToYpos) + } + else if (missile_5.opacity<1) { + missile_5.fire(aXpox,aFromYpos,aToYpos) + } +} + +// --------------------------------------------------------------------------- +// Fire enemy missile +function fireEnemyMissile(aXpox, aFromYpos, aToYpos) { + if (enemy_missile_1.opacity==0) { + enemy_missile_1.enemyFire(aXpox,aFromYpos,aToYpos) + } + else if (enemy_missile_2.opacity==0) { + enemy_missile_2.enemyFire(aXpox,aFromYpos,aToYpos) + } +} + +// --------------------------------------------------------------------------- +// Create level QML component +function createLevel() { + console.log("Creating level "+LevelPlugin.qmlRootPath()+"Level.qml") + var levelComponent = Qt.createComponent("file:/"+LevelPlugin.qmlRootPath()+"Level.qml"); + if (levelComponent.status == Component.Ready) { + if (levelPlugin) { + deleteLevel() + } + levelPlugin = levelComponent.createObject(levelId); + if (levelPlugin != null) { + console.log("Level created") + } else { + console.log("Can not create level") + messageBox.showErrorMessage("ERROR: Can not create level!",6000) + return 1 + } + } else { + console.log("Can not find level, error:"+levelComponent.errorString()) + messageBox.showErrorMessage("ERROR: Can not find level!",6000) + return 1 + } + + missile_1.createGraphicsForLevel() + missile_1.setToDefaultPos() + missile_2.createGraphicsForLevel() + missile_2.setToDefaultPos() + missile_3.createGraphicsForLevel() + missile_3.setToDefaultPos() + missile_4.createGraphicsForLevel() + missile_4.setToDefaultPos() + missile_5.createGraphicsForLevel() + missile_5.setToDefaultPos() + enemy_missile_1.createGraphicsForLevel() + enemy_missile_2.createGraphicsForLevel() + myShip.createGraphicsForLevel() + + return 0 +} + +// --------------------------------------------------------------------------- +// Delete level +function deleteLevel() { + if (levelPlugin) { + GameEngine.clearQmlObjects() + levelPlugin.destroy() + + } + levelPlugin = null; +} diff --git a/demos/mobile/quickhit/Game.qml b/demos/mobile/quickhit/Game.qml new file mode 100644 index 0000000..ab62a72 --- /dev/null +++ b/demos/mobile/quickhit/Game.qml @@ -0,0 +1,439 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 1.0 +import "Game.js" as GameScript + +Item { + id: gameArea + width: 360; height: 640 // NOTE: have to exists some default sizes + anchors.fill: parent + objectName: "gameArea" + + + // Who win, you or computer + property bool gameOverProperty: false + + // for info message to user + property variant messageBox + + // Level activated signal for Qt side to load activated level + signal levelActivated(int index) + + // Pause whole game, if level is loaded + function pauseGame() { + if (GameScript.levelPlugin) { + GameScript.pauseGame(true) + myShip.focus = false + btnPause.opacity = 0 + menu.showPauseMenu() + } + } + + // Qt side call this for QML take new level into use + function levelReadyForCreation() { + // Hide menu + menu.hideMenu() + // Show message + message.showMessage("Loading Level...",2000) + // Wait before create level + levelCreationTimer.restart() + } + + // Fires ememy missile. Function is called from Qt side + function fireEnemyMissile(aXpox, aFromYpos, aToYpos) { + GameScript.fireEnemyMissile(aXpox, aFromYpos, aToYpos) + } + + // Game Over handling. Function is called from Qt side + function gameOver(youWin) { + // Stop GameEngine timers + GameEngine.enableEngineTimer(false) + gameOverProperty = youWin + GameScript.hideMissiles() + gameOverTimer.restart() + //GameEngine.vibra() + } + + // End game and show menu + function endGame(showMessage) { + backgroundPic.opacity = 1 + // Stop GameEngine timers + GameEngine.enableEngineTimer(false) + // Do game over + GameScript.gameOver() + GameScript.hideMissiles() + // Clear GameEngine QML objects + GameEngine.clearQmlObjects() + myShip.opacity = 0 + myShip.focus = false + btnPause.opacity = 0 + idMainLogo.opacity = 1 + menu.showLevelMenu() + if (showMessage) { + message.showMessage("Game End",2000) + } + } + + // Timer for level creationing + Timer { + id: levelCreationTimer + interval: 1000; running: false; repeat: false + onTriggered: { + btnPause.opacity = 1 + myShip.opacity = 1 + myShip.focus = true + // Create new level + var ret = GameScript.createLevel() + if (ret==0) { + backgroundPic.opacity = 0 + // Find QML object for GameEngine + GameEngine.findQmlObjects() + // Enable GameEngine timer + GameEngine.enableEngineTimer(true) + } else { + // Level cannot be created! + endGame(false) + } + } + } + + // Timer for game over + Timer { + id: gameOverTimer + interval: 1500; running: false; repeat: false + onTriggered: { + backgroundPic.opacity = 1 + idMainLogo.opacity = 1 + // Do game over + GameScript.gameOver() + // Clear GameEngine QML objects + GameEngine.clearQmlObjects() + menu.showLevelMenu() + if (gameOverProperty) { + GameEngine.playInternalSound(4) + message.showMessage("Game Over, You win!",2000) + } else { + GameEngine.playInternalSounds(3,3) + message.showMessage("Game Over, You lose",2000) + } + } + } + + // Menu signal to slot connections + Connections { + target: menu + // Level selected + onLevelSelected: { + // Stop bigship animation + bigShipAnim.stop() + bigShip.opacity = 0 + // Hide logo + idMainLogo.opacity = 0 + // Signal level activated + gameArea.levelActivated(levelIndex) + } + // Level resumed selected + onResumeSelected: { + menu.hideMenu() + GameScript.pauseGame(false) + myShip.focus = true + } + } + + // This component creation completed + Component.onCompleted: { + // Show main Level selection menu + menu.showLevelMenu() + + // Start big ship animation + bigShipAnim.restart() + + // Set variable + messageBox = message + + // Play game start sound + GameEngine.gameStartSound() + + // Fade splash screen + fadeAnim.restart() + // Rotate splash logo + rotAnim.restart() + } + + + // Background image for the game + Image { + id: backgroundPic + z:1 + source: "qrc:/gfx/background2.png" + fillMode: Image.PreserveAspectCrop + smooth: true + anchors.fill: parent + } + + Image { + id: bigShip + source: "qrc:/gfx/bigship.png" + z:1.5 + smooth: true + x: width * -1 + y: parent.height * 0.55 + } + SequentialAnimation { + id: bigShipAnim; + NumberAnimation {target:bigShip; property:"x"; to:gameArea.width; easing.type: Easing.Linear; duration: 80000 } + PropertyAction {target:bigShip; properties: "opacity"; value: 0} + } + + + // Enemies grid + Item { + // This is general level QML plaseholder + // Into this is level QML created in createLevel() + id:levelId + anchors.fill: parent + z:2 + } + + Image { + id: idMainLogo + z:19 + source: "qrc:/gfx/quickhit_logo.png" + smooth: true + anchors.horizontalCenter: gameArea.horizontalCenter + y:gameArea.height / 10 * 1 + } + + // Game menu + Menu { + z:20 + id:menu + width: gameArea.width / 5 * 4 + height: gameArea.height / 10 * 4 + anchors.verticalCenter: gameArea.verticalCenter + anchors.horizontalCenter: gameArea.horizontalCenter + } + + // My ship + MyShip { + z:10 + id: myShip + opacity: 0 + } + + // Mouse area of your ship + MouseArea { + //anchors.fill: parent + width: parent.width + height: myShip.height + x:0 + y:gameArea.height - myShip.height + + drag.target: myShip + drag.axis: Drag.XAxis + drag.minimumX: 0 + drag.maximumX: gameArea.width - myShip.width + + property int startPos: 0 + property int dragCount: 0 + + onPressed: { + startPos = mouseX + dragCount = 0 + } + onPositionChanged: { + //dragCount = Math.abs(mouseX-startPos) + } + onReleased: { + //if (dragCount<20) { + myShip.fire() + //} + } + } + + // Pause button + Button { + id: btnSound + z:12 + //animationEnabled: false + anchors.top: parent.top + anchors.topMargin: 10 + buttonPath: "qrc:/gfx/soundOn.png" + buttonId: 4 + width: gameArea.width / 10 + height: gameArea.width / 10 + x: gameArea.width - width - 15 + opacity: 1 + Connections { + target: btnSound + onBtnClicked: { + if (btnSound.buttonId==4) { + // Sound off + btnSound.buttonPath = "qrc:/gfx/soundOff.png" + btnSound.buttonId = 5 + GameEngine.enableSounds(false) + } else { + // Sound on + btnSound.buttonPath = "qrc:/gfx/soundOn.png" + btnSound.buttonId = 4 + GameEngine.enableSounds(true) + } + } + } + } + + // Pause button + Button { + id: btnPause + z:13 + anchors.top: parent.top + anchors.topMargin: 10 + buttonPath: "qrc:/gfx/pause.png" + buttonId: 3 + width: gameArea.width / 10 + height: gameArea.width / 10 + x: gameArea.width - width - btnPause.width - 15*2 + opacity: 0 + Connections { + target: btnPause + onBtnClicked: { + GameScript.pauseGame(true) + myShip.focus = false + btnPause.opacity = 0 + menu.showPauseMenu() + } + } + } + + + // Hidden missiles ready for to be launched + Missile { + z:3 + id: missile_1 + x:0 + y:10 + } + Missile { + z:4 + id: missile_2 + x: 20 + y:10 + } + Missile { + z:5 + id: missile_3 + x: 40 + y:10 + } + Missile { + z:6 + id: missile_4 + x: 60 + y:10 + } + Missile { + z:7 + id: missile_5 + x: 80 + y:10 + } + Missile { + z:8 + objectName: "enemy_missile" + id: enemy_missile_1 + enemyMissile: true + } + Missile { + z:9 + objectName: "enemy_missile" + id: enemy_missile_2 + enemyMissile: true + } + + // Messages to the user + Message { + id: message + z:21 + } + + + // Splach screen + Rectangle { + id: blackFace + x:-2 + y:0 + width: parent.width + 2 + height: parent.height + z:100 + color: "black" + opacity: 1 + + MouseArea { + anchors.fill: parent + onPressed: { + mouse.accepted = true + fadeAnim.stop() + blackFace.opacity = 0 + } + } + + Image { + id: idLogo + source: "qrc:/gfx/quickhit_logo.png" + smooth: true + anchors.horizontalCenter: parent.horizontalCenter + anchors.verticalCenter: parent.verticalCenter + opacity: 0 + } + NumberAnimation { id: rotAnim; target: idLogo; property: "rotation"; to: 20; duration: 9000 } + + } + // Splach screen animation + SequentialAnimation { + id: fadeAnim + PauseAnimation {duration: 1000 } + NumberAnimation {target: idLogo; property: "opacity"; from: 0; to: 1; duration: 2000 } + PauseAnimation {duration: 2000 } + NumberAnimation {target: idLogo; property: "opacity"; from: 1; to: 0; duration: 2000 } + NumberAnimation {target: blackFace; property: "opacity"; from: 1; to: 0; duration: 2000 } + } + +} diff --git a/demos/mobile/quickhit/InvSounds.cpp b/demos/mobile/quickhit/InvSounds.cpp new file mode 100644 index 0000000..7342ba2 --- /dev/null +++ b/demos/mobile/quickhit/InvSounds.cpp @@ -0,0 +1,189 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "InvSounds.h" +#include <QDir> +#include <QDebug> + +using namespace GE; + +CInvSounds::CInvSounds(QObject *parent) : QObject( parent ) +{ + m_musicInstance = 0; + m_sounds = 0; + m_internalSounds = 0; + m_soundCount = 0; + m_internalSoundCount = 0; + + enableSounds(true); + + m_audioOut = new AudioOut( this, &m_mixer ); + + enableInternalSounds(); +} + +void CInvSounds::enableSounds(bool enable) +{ + if (enable) + m_mixer.setGeneralVolume(0.2f); + else + m_mixer.setGeneralVolume(0); +} + +void CInvSounds::enableInternalSounds() +{ + disableInternalSounds(); + + // Application internal sounda + m_internalSoundPaths.append(":/sound/menu1.wav"); + m_internalSoundPaths.append(":/sound/menu2.wav"); + m_internalSoundPaths.append(":/sound/gamestart.wav"); + m_internalSoundPaths.append(":/sound/gameover.wav"); + m_internalSoundPaths.append(":/sound/youwin.wav"); + + m_internalSoundCount = m_internalSoundPaths.count(); + m_internalSounds = new CAudioBuffer*[m_internalSoundCount]; + + // Load general application sounds + for (int ff=0; ff<m_internalSoundPaths.count(); ff++) { + m_internalSounds[ff] = CAudioBuffer::loadWav(m_internalSoundPaths[ff]); + } +} + +void CInvSounds::enableSounds(QStringList sounds) +{ + disableSounds(); + + // Sounds from the level + m_soundPaths = sounds; + m_soundCount = sounds.count(); + m_sounds = new CAudioBuffer*[m_soundCount]; + // Load level sounds + for (int f=0; f<m_soundPaths.count(); f++) { + m_sounds[f] = CAudioBuffer::loadWav(m_soundPaths[f]); + } + +} + +void CInvSounds::disableInternalSounds() +{ + for (int f=0; f<m_internalSoundCount; f++) { + if (m_internalSounds[f]) { + delete m_internalSounds[f]; + } + } + delete [] m_internalSounds; + m_internalSoundCount = 0; + m_internalSoundPaths.clear(); + + m_musicInstance = 0; +} + +void CInvSounds::disableSounds() +{ + for (int f=0; f<m_soundCount; f++) { + if (m_sounds[f]) { + delete m_sounds[f]; + } + } + delete [] m_sounds; + m_sounds = 0; + m_soundCount = 0; + m_soundPaths.clear(); + + m_musicInstance = 0; +} + +CInvSounds::~CInvSounds() { + if (m_audioOut) { + delete m_audioOut; + m_audioOut = 0; + } + + disableSounds(); + disableInternalSounds(); +} + + +void CInvSounds::beginMusicOn() { + m_musicInstance = (GE::CAudioBufferPlayInstance*)m_mixer.addAudioSource( new GE::CAudioBufferPlayInstance( m_sounds[0] ) ); + m_musicInstance->setLoopTimes(-1); +} + + +void CInvSounds::beginMusicOff() { + if (!m_musicInstance) return; + m_musicInstance->setLoopTimes(0); // stop when finished + m_musicInstance = 0; +}; + + +void CInvSounds::playSound(int index) { + if (index < m_soundCount && index > -1) { + m_sounds[index]->playWithMixer( m_mixer ); + } +} + +void CInvSounds::playSounds(int index, int count) +{ + if (index < m_soundCount && index > -1) { + CAudioBufferPlayInstance* i = m_sounds[index]->playWithMixer( m_mixer ); + i->setLoopTimes(count); + } +} + +void CInvSounds::playInternalSound(int index) { + if (index < m_internalSoundCount && index > -1) { + m_internalSounds[index]->playWithMixer( m_mixer ); + } +} + +void CInvSounds::playInternalSounds(int index, int count) +{ + if (index < m_internalSoundCount && index > -1) { + CAudioBufferPlayInstance* i = m_internalSounds[index]->playWithMixer( m_mixer ); + i->setLoopTimes(count); + } +} + +void CInvSounds::gameStartSound() { + CAudioBufferPlayInstance* i = m_internalSounds[2]->playWithMixer( m_mixer ); + i->setLoopTimes(2); +}; diff --git a/demos/mobile/quickhit/InvSounds.h b/demos/mobile/quickhit/InvSounds.h new file mode 100644 index 0000000..65422f2 --- /dev/null +++ b/demos/mobile/quickhit/InvSounds.h @@ -0,0 +1,91 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef __CINVSOUNDS__ +#define __CINVSOUNDS__ + +#include <QObject> +#include <QStringList> + +#include "ga_src/GEAudioBuffer.h" +#include "ga_src/GEAudioOut.h" + +class CInvSounds : public QObject +{ + Q_OBJECT + +public: + CInvSounds(QObject *parent); + ~CInvSounds(); + + void enableInternalSounds(); + void enableSounds(QStringList sounds); + void disableInternalSounds(); + void disableSounds(); + + void beginMusicOn(); + void beginMusicOff(); + + void enableSounds(bool enable); + + + void gameStartSound(); + +public slots: + void playSound(int index); + void playSounds(int index, int count); + void playInternalSound(int index); + void playInternalSounds(int index, int count); + +protected: + QStringList m_soundPaths; + QStringList m_internalSoundPaths; + GE::CAudioBufferPlayInstance *m_musicInstance; + GE::CAudioMixer m_mixer; + GE::AudioOut *m_audioOut; + + GE::CAudioBuffer **m_sounds; + int m_soundCount; + + GE::CAudioBuffer **m_internalSounds; + int m_internalSoundCount; +}; + +#endif diff --git a/demos/mobile/quickhit/Menu.qml b/demos/mobile/quickhit/Menu.qml new file mode 100644 index 0000000..cf2351e --- /dev/null +++ b/demos/mobile/quickhit/Menu.qml @@ -0,0 +1,163 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 1.0 +import "Game.js" as GameScript + + +Rectangle { + id: menu + + Text { + id: title + smooth: true + anchors.bottom: menu.top + anchors.horizontalCenter: menu.horizontalCenter + color: "red" + font.pixelSize: gameArea.width / 12 + font.bold: true + horizontalAlignment: Text.AlignHCenter + } + + border.color: "black" + border.width: 2 + radius: 8 + smooth: true + opacity: 0 // transparent by default + + color: "black" +// gradient: Gradient { +// GradientStop { position: 0.0; color: "white" } +// GradientStop { position: 1.0; color: "black" } +// } + + // Signals + signal levelSelected(int levelIndex) + signal resumeSelected() + + // Show level menu + function showLevelMenu() { + menuData.clear() + title.text = "Select Your Level" + var plugins = GameEngine.pluginList() + for (var i = 0; i < plugins.length; i++) { + menuData.append({"name": plugins[i],"type":"0"}) + } + menuData.append({"name": "About","type":"4"}) + menuData.append({"name": "Exit","type":"1"}) + menu.opacity = 0.8 + listView.focus = true + } + + function showPauseMenu() { + menuData.clear() + title.text = "Resume level?" + menuData.append({"name": "Resume","type":"2"}) + menuData.append({"name": "End Game","type":"3"}) + menu.opacity = 0.8 + listView.focus = true + } + + // Hide menu + function hideMenu() { + menu.opacity = 0 + listView.focus = false + } + + function menuItemSelected(index, type) { + switch (type) { + case "0": { + // Level selection + menu.levelSelected(index) + break; + } + case "1": { + // Exit + Qt.quit() + break; + } + case "2": { + // Resume + menu.resumeSelected() + break; + } + case "3": { + // End Game + gameArea.endGame() + break; + } + case "4": { + // Show about + gameArea.messageBox.showInfoMessage() + break; + } + default: { + break; + } + } + } + + ListModel { + id: menuData + } + + ListView { + id: listView + clip: true + anchors.fill: parent + keyNavigationWraps: true + + function doSelect() { + menu.menuItemSelected(listView.currentIndex,menuData.get(listView.currentIndex).type) + } + + model: menuData + + delegate: MenuItem { + id: menuItem + selectedItem: menuItem.ListView.isCurrentItem ? true : false + onItemSelected: { + listView.currentIndex = model.index + listView.doSelect() + } + + } + } +} diff --git a/demos/mobile/quickhit/MenuItem.qml b/demos/mobile/quickhit/MenuItem.qml new file mode 100644 index 0000000..58557ac --- /dev/null +++ b/demos/mobile/quickhit/MenuItem.qml @@ -0,0 +1,103 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 1.0 + +Text { + id: menuItem + text: name + color: "white" + opacity: 1 + font.family: "Calibri" + font.pixelSize: menu.width / 8 + x: (parent.width - width )/ 2 + + property bool selectedItem: false + property int type + + signal itemSelected() + + transform: Rotation { id:rotationId; origin.x:width/2; origin.y:height/2; axis { x: 1; y: 0; z: 0 } angle: 0 } + SequentialAnimation { + id: toRotateRightAndCenterAnim + PropertyAnimation { target: rotationId; easing.type: Easing.Linear; + properties: "angle"; from: 0; to: 180; duration: 300 } + PropertyAction { target: menuItem; property: "color"; value:"red"} + PropertyAnimation { target: rotationId; easing.type: Easing.Linear; + properties: "angle"; from: 180; to: 360; duration: 300 } + PropertyAction { target: menuItem; property: "color"; value:"white"} + } + + function selectItem(doSelect) { + if (!toRotateRightAndCenterAnim.running) { + GameEngine.playInternalSound(0) + toRotateRightAndCenterAnim.restart() + if (doSelect) { + GameEngine.playInternalSound(1) + selectionTimer.restart() + } + } + } + + Timer { + id: selectionTimer + interval: 1000; running: false; repeat: false + onTriggered: menuItem.itemSelected() + } + + MouseArea { + id: mouseArea; + anchors.fill: parent + onClicked: { + selectItem(true) + } + } + + Keys.onSpacePressed: { selectItem(true) } + Keys.onSelectPressed: { selectItem(true) } + Keys.onEnterPressed: { selectItem(true) } + Keys.onReleased: { + if (event.key == Qt.Key_Down || event.key == Qt.Key_Up) { + selectItem(false) + } + event.accepted = false + } +} + diff --git a/demos/mobile/quickhit/Message.qml b/demos/mobile/quickhit/Message.qml new file mode 100644 index 0000000..1498203 --- /dev/null +++ b/demos/mobile/quickhit/Message.qml @@ -0,0 +1,147 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 1.0 + +Rectangle { + id: message + border.color: "black" + border.width: 1 + radius: 8 + smooth: true + opacity: 0 // transparent = 0 by default + color: "black" + + property string txt + property int animSpeed + + function showMessage(text,speed) { + message.border.color = "black" + message.y = 50 + message.width = gameArea.width / 5 * 4 + message.height = gameArea.height / 8 * 1 + txt = text + animSpeed = speed + message.opacity = 1 + messageText.font.pixelSize = parent.width / 14 + messageAnim.restart() + } + + function showErrorMessage(text,speed) { + message.border.color = "red" + message.y = 50 + message.width = gameArea.width / 5 * 4 + message.height = gameArea.height / 8 * 1 + txt = text + animSpeed = speed + message.opacity = 1 + messageText.font.pixelSize = parent.width / 14 + messageAnim.restart() + } + + function showInfoMessage() { + message.border.color = "white" + txt = "<a href=\"https://projects.forum.nokia.com/quickhit\">QuickHit</a>" + + "<p>" + + "Forum Nokia <br>" + + "Qt Quick Game Example <br>" + + "</p>" + + "<p>" + + "Sounds were loaded from freesound.org under Creative Commons Sampling Plus 1.0 license.<br>" + + "</p>" + + "<p>" + + "Sounds were created by these nicknames:<br>" + + "HardPCM<br>" + + "Matt_G<br>" + + "klankbeeld<br>" + + "steveygos93<br>" + + "joe93barlow<br>" + + "ljudman<br>" + + "Jovica<br>" + + "patchen<br>" + + "nthompson<br>" + + "</p>" + + animSpeed = 9000 + message.opacity = 1 + message.y = 10 + message.height = gameArea.height - message.y - 10 + message.width = gameArea.width - 20 + + messageText.font.pixelSize = parent.width / 16 + messageAnim.restart() + } + + //gradient: Gradient { + // GradientStop { position: 0.0; color: "white" } + // GradientStop { position: 1.0; color: "black" } + //} + + SequentialAnimation { + id: messageAnim + PropertyAnimation { + target: message; properties: "x"; + from: message.width*-1; to: gameArea.width; duration: animSpeed; easing.type: Easing.OutInExpo} + PropertyAction { target: message; properties: "opacity"; value: 0 } + } + + MouseArea { + anchors.fill: parent + onClicked: { + messageAnim.stop() + message.opacity = 0 + } + } + + Text { + id: messageText + anchors.fill: parent + anchors.margins: 10 + text: txt + wrapMode: Text.WordWrap + color: "white" + font.family: "Calibri" + font.pixelSize: parent.width / 14 + font.bold: true + onLinkActivated: { + GameEngine.openLink(link) + } + } +} diff --git a/demos/mobile/quickhit/Missile.qml b/demos/mobile/quickhit/Missile.qml new file mode 100644 index 0000000..80efa6e --- /dev/null +++ b/demos/mobile/quickhit/Missile.qml @@ -0,0 +1,143 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 1.0 + +Item { + id: missile + objectName: "missile" + opacity: 0 // transparent by default + + property int fromYpos + property int toYpos + property variant myMissileSize + property bool enemyMissile: false + property int defaultX: 0 + property int defaultY: 0 + + function storeDefaultPos() { + defaultX = missile.x + defaultY = missile.y + } + + function setToDefaultPos() { + missile.x = defaultX + missile.y = defaultY + opacity = 0.5 + } + + function createGraphicsForLevel() { + missile.myMissileSize = LevelPlugin.graphSize(LevelPlugin.pathToMissilePic()) + missile.height = myMissileSize.height; + missile.width = myMissileSize.width; + if (missile.enemyMissile) { + missileImage.source = "file:/"+LevelPlugin.pathToEnemyMissilePic() + } else { + missileImage.source = "file:/"+LevelPlugin.pathToMissilePic() + } + } + + // Execute fire! + function fire(aXpox, aFromYpos, aToYpos) { + missile.x = aXpox - missile.width / 2 + missile.y = aFromYpos + missile.fromYpos = aFromYpos + missile.toYpos = aToYpos + missile.opacity = 1 + GameEngine.playSound(2) // NOTE: 3 for your missile sound + flying.restart() + } + + // Enemy fires! + function enemyFire(aXpox, aFromYpos, aToYpos) { + missile.x = aXpox - missile.width / 2 + missile.y = aFromYpos + missile.fromYpos = aFromYpos + missile.toYpos = aToYpos + missile.opacity = 1 + GameEngine.playSound(3) // NOTE: 3 for enemy missile sound + flyingEnemy.restart() + } + + // Stop missile + function stop() { + flying.stop() + } + + // Pause missile + function pause(doPause) { + if (doPause) { + flying.pause() + flyingEnemy.pause() + } else { + flying.resume() + flyingEnemy.resume() + } + } + + Component.onCompleted: { + if (!enemyMissile) { + storeDefaultPos() + setToDefaultPos() + } + } + + // Animates missile flying to the target + SequentialAnimation { + id: flying + PropertyAnimation {target: missile; properties: "y"; + from: fromYpos; to: toYpos; duration: 2000; easing.type: Easing.InCubic } + //PropertyAction {target: missile; properties: "opacity"; value: 0} + ScriptAction { script: setToDefaultPos() } + } + + SequentialAnimation { + id: flyingEnemy + PropertyAnimation {target: missile; properties: "y"; + from: fromYpos; to: toYpos; duration: 2000; easing.type: Easing.InCubic } + PropertyAction {target: missile; properties: "opacity"; value: 0} + } + + Image { + id: missileImage + smooth: true + } +} + diff --git a/demos/mobile/quickhit/MyShip.qml b/demos/mobile/quickhit/MyShip.qml new file mode 100644 index 0000000..3bcc822 --- /dev/null +++ b/demos/mobile/quickhit/MyShip.qml @@ -0,0 +1,184 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 1.0 +import "Game.js" as GameScript + +Item { + id: myShip + objectName: "myShip" + + property variant myShipSize + property int originalY + + // Fires missile if exists + function fire() { + if (myShip.opacity==1) { + GameScript.fireMissile(myShip.x+myShip.width/2,myShip.y,myShip.height*-1) + if (myShip.y+myShip.height < gameArea.height+5) { + goDownAnim.restart() + } + } + } + + function createGraphicsForLevel() { + myShip.myShipSize = LevelPlugin.graphSize(LevelPlugin.pathToMyShipPic()) + myShip.height = myShipSize.height + myShip.width = myShipSize.width + image.source = "file:/"+LevelPlugin.pathToMyShipPic() + myShip.y = gameArea.height - myShip.height - 10 + originalY = myShip.y + myShip.x = (gameArea.width - myShip.width)/ 2 + } + + Image { + id: image + smooth: true + } + + Keys.onSpacePressed: { fire() } + Keys.onSelectPressed: { fire() } + Keys.onRightPressed: { + if (myShip.x < (gameArea.width - myShip.width - 20)) { + toRightAnim.restart() + } + } + Keys.onLeftPressed: { + if (myShip.x > 20) { + toLeftAnim.restart() + } + } + + // To right animation + PropertyAnimation { id: toRightAnim; target: myShip; easing.type: Easing.OutQuint; + properties: "x"; from: myShip.x; to: myShip.x + 20; duration: 500 } + + // To left animation + PropertyAnimation { id: toLeftAnim; target: myShip; easing.type: Easing.OutQuint; + properties: "x"; from: myShip.x; to: myShip.x - 20; duration: 500 } + + // Go down on fire animation + SequentialAnimation { + id: goDownAnim + NumberAnimation { target: myShip; property:"y"; from: myShip.y; to: myShip.y+5; + easing.type: Easing.Linear; duration: 200 } + NumberAnimation { target: myShip; property:"y"; from: myShip.y; to: originalY; + easing.type: Easing.Linear; duration: 200 } + } + + + /* + MouseArea { + anchors.fill: parent + drag.target: myShip + drag.axis: Drag.XAxis + drag.minimumX: 0 + drag.maximumX: gameArea.width - myShip.width + onReleased: { + fire() + } + } + */ + + + /* + property bool isAutoRepeat: false + Keys.onPressed: { + if (event.key == Qt.Key_Right) { + if (event.isAutoRepeat) { + isAutoRepeat = true + toRightAnim.restart() + } else { + isAutoRepeat = false + toRotateRightAndCenterAnim.restart() + } + event.accepted = true + } + else if (event.key == Qt.Key_Left) { + if (event.isAutoRepeat) { + isAutoRepeat = true + toLeftAnim.restart() + } else { + isAutoRepeat = false + toRotateLeftAndCenterAnim.restart() + } + event.accepted = true + } + } + + Keys.onReleased: { + if (isAutoRepeat) { + toRotateRightAndCenterAnim.stop() + toRotateLeftAndCenterAnim.stop() + } else { + toRotateCenter.restart() + } + event.accepted = true + } + + // Rotation on movement animation + transform: Rotation { id:rotationId; origin.x: width/2; origin.y: height/2; axis { x: 0; y: 1; z: 0 } angle: 0 } + SequentialAnimation { + id: toRotateRightAndCenterAnim + PropertyAnimation { target: rotationId; easing.type: Easing.Linear; + properties: "angle"; from: 0; to: 30; duration: 100 } + PropertyAnimation { target: myShip; easing.type: Easing.OutQuint; + properties: "x"; from: myShip.x; to: myShip.x + 20; duration: 500 } + PropertyAnimation { target: rotationId; easing.type: Easing.Linear; + properties: "angle"; to: 0; duration: 100 } + } + SequentialAnimation { + id: toRotateLeftAndCenterAnim + PropertyAnimation { target: rotationId; easing.type: Easing.Linear; + properties: "angle"; from: 0; to: -30; duration: 100 } + PropertyAnimation { target: myShip; easing.type: Easing.OutQuint; + properties: "x"; from: myShip.x; to: myShip.x - 20; duration: 500 } + PropertyAnimation { target: rotationId; easing.type: Easing.Linear; + properties: "angle"; to: 0; duration: 100 } + } + PropertyAnimation { id: toRotateRight; target: rotationId; easing.type: Easing.Linear; + properties: "angle"; from: 0; to: 30; duration: 100 } + PropertyAnimation { id: toRotateCenter; target: rotationId; easing.type: Easing.Linear; + properties: "angle"; to: 0; duration: 100 } + PropertyAnimation { id: toRotateLeft; target: rotationId; easing.type: Easing.Linear; + properties: "angle"; from: 0; to: -30; duration: 100 } +*/ + +} diff --git a/demos/mobile/quickhit/debian/changelog b/demos/mobile/quickhit/debian/changelog new file mode 100644 index 0000000..226e172 --- /dev/null +++ b/demos/mobile/quickhit/debian/changelog @@ -0,0 +1,11 @@ +quickhit (1.1.0) unstable; urgency=low + + * First version + + -- Antonio Aloisio <antonio.aloisio@nokia.com> Wed, 5 Jan 2011 10:05:04 +0200 + +quickhit (1.0.0) unstable; urgency=low + + * First version + + -- Antonio Aloisio <antonio.aloisio@nokia.com> Tue, 19 Oct 2010 10:05:04 +0200 diff --git a/demos/mobile/quickhit/debian/compat b/demos/mobile/quickhit/debian/compat new file mode 100644 index 0000000..7f8f011 --- /dev/null +++ b/demos/mobile/quickhit/debian/compat @@ -0,0 +1 @@ +7 diff --git a/demos/mobile/quickhit/debian/control b/demos/mobile/quickhit/debian/control new file mode 100644 index 0000000..7253285 --- /dev/null +++ b/demos/mobile/quickhit/debian/control @@ -0,0 +1,11 @@ +Source: quickhit +Section: user/games +Priority: extra +Maintainer: Antonio Aloisio <antonio.aloisio@nokia.com> +Standards-Version: 3.7.2 + +Package: quickhit +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends} +Description: QuickHit + Qt Quick Game example diff --git a/demos/mobile/quickhit/debian/copyright b/demos/mobile/quickhit/debian/copyright new file mode 100644 index 0000000..b0aadaf --- /dev/null +++ b/demos/mobile/quickhit/debian/copyright @@ -0,0 +1,8 @@ +This is quickhit, written and maintained by Forum Nokia Antonio Aloisio <antonio.aloisio@nokia.com> +on Tue, 19 Oct 2010 10:05:04 +0200 + + +Copyright Holder: Nokia (c) 2010 + +License: + diff --git a/demos/mobile/quickhit/debian/dirs b/demos/mobile/quickhit/debian/dirs new file mode 100644 index 0000000..80507f1 --- /dev/null +++ b/demos/mobile/quickhit/debian/dirs @@ -0,0 +1,2 @@ +usr/bin +usr/share/applications/hildon diff --git a/demos/mobile/quickhit/debian/postinst b/demos/mobile/quickhit/debian/postinst new file mode 100644 index 0000000..79fb6dd --- /dev/null +++ b/demos/mobile/quickhit/debian/postinst @@ -0,0 +1,5 @@ +#!/bin/sh -e + +gtk-update-icon-cache -f /usr/share/icons/hicolor + +exit 0 diff --git a/demos/mobile/quickhit/debian/rules b/demos/mobile/quickhit/debian/rules new file mode 100644 index 0000000..b485428 --- /dev/null +++ b/demos/mobile/quickhit/debian/rules @@ -0,0 +1,91 @@ +#!/usr/bin/make -f +# -*- makefile -*- +# Sample debian/rules that uses debhelper. +# This file was originally written by Joey Hess and Craig Small. +# As a special exception, when this file is copied by dh-make into a +# dh-make output file, you may use that output file without restriction. +# This special exception was added by Craig Small in version 0.37 of dh-make. + +# Uncomment this to turn on verbose mode. +#export DH_VERBOSE=1 + + +APPNAME := quickhit + + +configure: configure-stamp +configure-stamp: + dh_testdir + # Add here commands to configure the package. + + touch configure-stamp + + +build: build-stamp + +build-stamp: configure-stamp + dh_testdir + + # Add here commands to compile the package. + $(MAKE) + #docbook-to-man debian/$(APPNAME).sgml > $(APPNAME).1 + + touch $@ + +clean: + dh_testdir + dh_testroot + rm -f build-stamp configure-stamp + + # Add here commands to clean up after the build process. + $(MAKE) clean + + dh_clean + +install: build + dh_testdir + dh_testroot + dh_clean -k + dh_installdirs + + # Add here commands to install the package into debian/$(APPNAME). + $(MAKE) INSTALL_ROOT="$(CURDIR)"/debian/$(APPNAME) install + + +# Build architecture-independent files here. +binary-indep: build install +# We have nothing to do by default. + +# Build architecture-dependent files here. +binary-arch: build install + dh_testdir + dh_testroot + dh_installchangelogs + dh_installdocs + dh_installexamples +# dh_install +# dh_installmenu +# dh_installdebconf +# dh_installlogrotate +# dh_installemacsen +# dh_installpam +# dh_installmime +# dh_python +# dh_installinit +# dh_installcron +# dh_installinfo + dh_installman + dh_link + # dh_strip + dh_compress + dh_fixperms +# dh_perl + dh_makeshlibs + dh_installdeb + dh_shlibdeps + dh_gencontrol + dh_md5sums + dh_builddeb + +binary: binary-indep binary-arch +.PHONY: build clean binary-indep binary-arch binary install configure diff --git a/demos/mobile/quickhit/freesound.org.licence.txt b/demos/mobile/quickhit/freesound.org.licence.txt new file mode 100644 index 0000000..8714ea0 --- /dev/null +++ b/demos/mobile/quickhit/freesound.org.licence.txt @@ -0,0 +1,24 @@ + +Sounds were loaded from www.freesound.org under Creative Commons Sampling Plus 1.0 license. + +Sounds were created by these nicknames: HardPCM, Matt_G, klankbeeld, steveygos93, joe93barlow, ljudman, Jovica, patchen, nthompson + +78677__joe93barlow__strike2.wav +47251__nthompson__rocket.wav +3378__patchen__Rhino_03.wav +3258__Jovica__Dronetail_02.wav +30351__Matt_G__Space_Fighter_Pass.wav +32954__HardPCM__Chip054.wav +32985__HardPCM__Alarm001.wav +33245__ljudman__grenade.wav +78678__joe93barlow__swing0.wav +80401__steveygos93__Explosion2.wav +109438__klankbeeld__intro_brass_01.wav + + + + + + + + diff --git a/demos/mobile/quickhit/ga_src/GEAudioBuffer.cpp b/demos/mobile/quickhit/ga_src/GEAudioBuffer.cpp new file mode 100644 index 0000000..7da9219 --- /dev/null +++ b/demos/mobile/quickhit/ga_src/GEAudioBuffer.cpp @@ -0,0 +1,391 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QDebug> +#include <math.h> +#include "GEAudioBuffer.h" + +using namespace GE; + + +struct SWavHeader { + char chunkID[4]; + unsigned int chunkSize; + char format[4]; + + unsigned char subchunk1id[4]; + unsigned int subchunk1size; + unsigned short audioFormat; + unsigned short nofChannels; + unsigned int sampleRate; + unsigned int byteRate; + + unsigned short blockAlign; + unsigned short bitsPerSample; + + unsigned char subchunk2id[4]; + unsigned int subchunk2size; + +}; + +CAudioBuffer::CAudioBuffer() { + m_data = 0; + m_dataLength = 0; + m_sampleFunction = 0; +}; + + +CAudioBuffer::~CAudioBuffer() { + reallocate(0); +} + +void CAudioBuffer::reallocate( int length ) { + if (m_data) delete [] ((char*)m_data); + m_dataLength = length; + if (m_dataLength>0) { + m_data = new char[ m_dataLength ]; + } else m_data = 0; +}; + + +CAudioBuffer* CAudioBuffer::loadWav( QString fileName ) { + QFile *wavFile = new QFile( fileName ); + + + if (wavFile->open(QIODevice::ReadOnly)) { + SWavHeader header; + + wavFile->read( header.chunkID, 4 ); + if (header.chunkID[0]!='R' || header.chunkID[1]!='I' || header.chunkID[2]!='F' || header.chunkID[3]!='F') return 0; // incorrect header + + wavFile->read( (char*)&header.chunkSize,4 ); + wavFile->read( (char*)&header.format,4 ); + + if (header.format[0]!='W' || header.format[1]!='A' || header.format[2]!='V' || header.format[3]!='E') return 0; // incorrect header + + wavFile->read( (char*)&header.subchunk1id,4 ); + if (header.subchunk1id[0]!='f' || header.subchunk1id[1]!='m' || header.subchunk1id[2]!='t' || header.subchunk1id[3]!=' ') return 0; // incorrect header + + wavFile->read( (char*)&header.subchunk1size,4 ); + wavFile->read( (char*)&header.audioFormat,2 ); + wavFile->read( (char*)&header.nofChannels,2 ); + wavFile->read( (char*)&header.sampleRate,4 ); + wavFile->read( (char*)&header.byteRate,4 ); + wavFile->read( (char*)&header.blockAlign,2 ); + wavFile->read( (char*)&header.bitsPerSample,2 ); + + qDebug() << fileName << " opened"; + + while (1) { + if (wavFile->read( (char*)&header.subchunk2id,4 ) != 4) return 0; + if (wavFile->read( (char*)&header.subchunk2size,4 ) != 4) return 0; + //int deb_size = header.subchunk2size; + //char tes[4]; + //memcpy(tes, header.subchunk2id, 4 ); + //if (header.subchunk2id[0]!='d' || header.subchunk2id[1]!='a' || header.subchunk2id[2]!='t' || header.subchunk2id[3]!='a') return 0; // incorrect header + if (header.subchunk2id[0]=='d' && header.subchunk2id[1]=='a' && header.subchunk2id[2]=='t' && header.subchunk2id[3]=='a') break; // found the data, chunk + // this was not the data-chunk. skip it + if (header.subchunk2size<1) return 0; // error in file + char *unused = new char[header.subchunk2size]; + wavFile->read( unused, header.subchunk2size ); + delete [] unused; + } + + + + // the data follows. + if (header.subchunk2size<1) return 0; + + CAudioBuffer *rval = new CAudioBuffer; + rval->m_nofChannels = header.nofChannels; + rval->m_bitsPerSample = header.bitsPerSample; + rval->m_samplesPerSec = header.sampleRate; + rval->m_signedData = 0; // where to know this? + rval->reallocate( header.subchunk2size ); + + wavFile->read( (char*)rval->m_data, header.subchunk2size ); + + // choose a good sampling function. + rval->m_sampleFunction = 0; + if (rval->m_nofChannels==1) { + if (rval->m_bitsPerSample == 8) rval->m_sampleFunction = sampleFunction8bitMono; + if (rval->m_bitsPerSample == 16) rval->m_sampleFunction = sampleFunction16bitMono; + } else { + if (rval->m_bitsPerSample == 8) rval->m_sampleFunction = sampleFunction8bitStereo; + if (rval->m_bitsPerSample == 16) rval->m_sampleFunction = sampleFunction16bitStereo; + } + + return rval; + + + } else { + qDebug() << fileName << " NOT opened"; + return 0; + } + + delete wavFile; +}; + + +CAudioBuffer* CAudioBuffer::loadWav( FILE *wavFile ) { + // read the header. + SWavHeader header; + fread( header.chunkID, 4, 1, wavFile ); + if (header.chunkID[0]!='R' || header.chunkID[1]!='I' || header.chunkID[2]!='F' || header.chunkID[3]!='F') return 0; // incorrect header + + fread( &header.chunkSize, 4, 1, wavFile ); + fread( header.format, 4, 1, wavFile ); + if (header.format[0]!='W' || header.format[1]!='A' || header.format[2]!='V' || header.format[3]!='E') return 0; // incorrect header + + fread( header.subchunk1id, 4, 1, wavFile ); + if (header.subchunk1id[0]!='f' || header.subchunk1id[1]!='m' || header.subchunk1id[2]!='t' || header.subchunk1id[3]!=' ') return 0; // incorrect header + + fread( &header.subchunk1size, 4, 1, wavFile ); + fread( &header.audioFormat, 2, 1, wavFile ); + fread( &header.nofChannels, 2, 1, wavFile ); + fread( &header.sampleRate, 4, 1, wavFile ); + fread( &header.byteRate, 4, 1, wavFile ); + + fread( &header.blockAlign, 2, 1, wavFile ); + fread( &header.bitsPerSample, 2, 1, wavFile ); + + fread( header.subchunk2id, 4, 1, wavFile ); + if (header.subchunk2id[0]!='d' || header.subchunk2id[1]!='a' || header.subchunk2id[2]!='t' || header.subchunk2id[3]!='a') return 0; // incorrect header + fread( &header.subchunk2size, 4, 1, wavFile ); + + + // the data follows. + if (header.subchunk2size<1) return 0; + + CAudioBuffer *rval = new CAudioBuffer; + rval->m_nofChannels = header.nofChannels; + rval->m_bitsPerSample = header.bitsPerSample; + rval->m_samplesPerSec = header.sampleRate; + rval->m_signedData = 0; // where to know this? + rval->reallocate( header.subchunk2size ); + + fread( rval->m_data, 1, header.subchunk2size, wavFile ); + + + + // choose a good sampling function. + rval->m_sampleFunction = 0; + if (rval->m_nofChannels==1) { + if (rval->m_bitsPerSample == 8) rval->m_sampleFunction = sampleFunction8bitMono; + if (rval->m_bitsPerSample == 16) rval->m_sampleFunction = sampleFunction16bitMono; + } else { + if (rval->m_bitsPerSample == 8) rval->m_sampleFunction = sampleFunction8bitStereo; + if (rval->m_bitsPerSample == 16) rval->m_sampleFunction = sampleFunction16bitStereo; + } + + return rval; +}; + + + +AUDIO_SAMPLE_TYPE CAudioBuffer::sampleFunction8bitMono( CAudioBuffer *abuffer, int pos, int channel ) { + return (AUDIO_SAMPLE_TYPE)(((unsigned char*)(abuffer->m_data))[pos]-128)<<8; +}; + +AUDIO_SAMPLE_TYPE CAudioBuffer::sampleFunction16bitMono( CAudioBuffer *abuffer, int pos, int channel ) { + return (AUDIO_SAMPLE_TYPE)(((short*)(abuffer->m_data))[pos]); +}; + +AUDIO_SAMPLE_TYPE CAudioBuffer::sampleFunction8bitStereo( CAudioBuffer *abuffer, int pos, int channel ) { + return ((AUDIO_SAMPLE_TYPE)(((char*)(abuffer->m_data))[pos*abuffer->m_nofChannels + channel])<<8); +}; + + +AUDIO_SAMPLE_TYPE CAudioBuffer::sampleFunction16bitStereo( CAudioBuffer *abuffer, int pos, int channel ) { + return (AUDIO_SAMPLE_TYPE)(((short*)(abuffer->m_data))[pos*abuffer->m_nofChannels + channel]); +}; + +CAudioBufferPlayInstance *CAudioBuffer::playWithMixer( CAudioMixer &mixer ) { + CAudioBufferPlayInstance *i = (CAudioBufferPlayInstance*)mixer.addAudioSource( new CAudioBufferPlayInstance( this )); + return i; +}; + + +CAudioBufferPlayInstance::CAudioBufferPlayInstance() { + m_fixedPos = 0; + m_fixedInc = 0; + m_buffer = 0; + m_fixedLeftVolume = 4096; + m_fixedRightVolume = 4096; + m_destroyWhenFinished = true; + m_finished = false; +}; + +CAudioBufferPlayInstance::CAudioBufferPlayInstance( CAudioBuffer *startPlaying ) { + m_fixedPos = 0; + m_fixedInc = 0; + m_fixedLeftVolume = 4096; + m_fixedRightVolume = 4096; + m_destroyWhenFinished = true; + m_finished = false; + playBuffer( startPlaying, 1.0f, 1.0f ); +}; + +void CAudioBufferPlayInstance::playBuffer( CAudioBuffer *startPlaying, float volume, float speed, int loopTimes ) { + m_buffer = startPlaying; + m_fixedLeftVolume = (int)(4096.0f*volume); + m_fixedRightVolume = m_fixedLeftVolume; + m_fixedPos = 0; + //m_fixedInc = ( startPlaying->getSamplesPerSec() * (int)(4096.0f*speed)) / AUDIO_FREQUENCY; + setSpeed( speed ); + m_loopTimes = loopTimes; + +}; + +CAudioBufferPlayInstance::~CAudioBufferPlayInstance() { + +}; + + +void CAudioBufferPlayInstance::stop() { + m_buffer = 0; + m_finished = true; +}; + +void CAudioBufferPlayInstance::setSpeed( float speed ) { + if (!m_buffer) return; + m_fixedInc = (int)( ((float)m_buffer->getSamplesPerSec() * 4096.0f*speed) / (float)AUDIO_FREQUENCY ); +}; + +void CAudioBufferPlayInstance::setLeftVolume( float vol ) { + m_fixedLeftVolume = (int)(4096.0f*vol); +}; + +void CAudioBufferPlayInstance::setRightVolume( float vol ) { + m_fixedRightVolume = (int)(4096.0f*vol); +}; + +bool CAudioBufferPlayInstance::canBeDestroyed() { + if (m_finished==true && + m_destroyWhenFinished==true) return true; else return false; +}; + + + +// Does not do any bound-checking. Must be checked before called. +int CAudioBufferPlayInstance::mixBlock( AUDIO_SAMPLE_TYPE *target, int samplesToMix ) { + SAMPLE_FUNCTION_TYPE sampleFunction = m_buffer->getSampleFunction(); + if (!sampleFunction) return 0; // unsupported sampletype + AUDIO_SAMPLE_TYPE *t_target = target+samplesToMix*2; + int sourcepos; + //int tempCounter = 0; + + if (m_buffer->getNofChannels() == 2) { // stereo + while (target!=t_target) { + sourcepos = m_fixedPos>>12; + target[0] = (((((sampleFunction)( m_buffer, sourcepos, 0) * (4096-(m_fixedPos&4095)) + (sampleFunction)( m_buffer, sourcepos+1, 0) * (m_fixedPos&4095) ) >> 12) * m_fixedLeftVolume) >> 12); + target[1] = (((((sampleFunction)( m_buffer, sourcepos, 1) * (4096-(m_fixedPos&4095)) + (sampleFunction)( m_buffer, sourcepos+1, 1) * (m_fixedPos&4095) ) >> 12) * m_fixedRightVolume) >> 12); + m_fixedPos+=m_fixedInc; + target+=2; + //tempCounter++; + }; + } else { // mono + int temp; + while (target!=t_target) { + sourcepos = m_fixedPos>>12; + temp = (((sampleFunction)( m_buffer, sourcepos, 0 ) * (4096-(m_fixedPos&4095)) + (sampleFunction)( m_buffer, sourcepos+1, 0 ) * (m_fixedPos&4095) ) >> 12); + target[0] = ((temp*m_fixedLeftVolume)>>12); + target[1] = ((temp*m_fixedRightVolume)>>12); + m_fixedPos+=m_fixedInc; + target+=2; + //tempCounter++; + }; + + }; + + return samplesToMix; +}; + + + +int CAudioBufferPlayInstance::pullAudio( AUDIO_SAMPLE_TYPE *target, int bufferLength ) { + if (!m_buffer) return 0; // no sample associated to mix.. + + int channelLength = ((m_buffer->getDataLength()) / (m_buffer->getNofChannels()*m_buffer->getBytesPerSample()))-2; + + int samplesToWrite = bufferLength/2; + int amount; + int totalMixed = 0; + + + while (samplesToWrite>0) { + int samplesLeft = channelLength - (m_fixedPos>>12); + int maxMixAmount = (int)(((long long int)(samplesLeft)<<12) / m_fixedInc ); // This is how much we can mix at least + //int maxMixAmount = (int)((float)samplesLeft / ((float)m_fixedInc/4096.0f)); + //if (maxMixAmount<1) maxMixAmount = 1; // NOTE, THIS MIGHT CAUSE PROBLEMS. NEEDS CHECKING + if (maxMixAmount>samplesToWrite) { + maxMixAmount=samplesToWrite; + } + + if (maxMixAmount > 0) { + amount=mixBlock(target+totalMixed * 2, maxMixAmount); + + if (amount == 0) + { + // Error! + break; + } + + totalMixed+=amount; + } else { + amount = 0; + m_fixedPos = channelLength<<12; + } + + // sample is ended,.. check the looping variables and see what to do. + if ((m_fixedPos>>12)>=channelLength) { + m_fixedPos -= (channelLength<<12); + if (m_loopTimes>0) m_loopTimes--; + if (m_loopTimes==0) { + stop(); + return totalMixed; + } + } + + samplesToWrite-=amount; + if (samplesToWrite<1) break; + }; + return totalMixed*2; +}; diff --git a/demos/mobile/quickhit/ga_src/GEAudioBuffer.h b/demos/mobile/quickhit/ga_src/GEAudioBuffer.h new file mode 100644 index 0000000..5fe5f00 --- /dev/null +++ b/demos/mobile/quickhit/ga_src/GEAudioBuffer.h @@ -0,0 +1,137 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef __GE_IGA_AUDIOBUFFER__ +#define __GE_IGA_AUDIOBUFFER__ + +#include <QFile> +#include "GEInterfaces.h" + + +namespace GE { + + class CAudioBufferPlayInstance; + class CAudioBuffer; // forward declaration + typedef AUDIO_SAMPLE_TYPE(*SAMPLE_FUNCTION_TYPE)(CAudioBuffer *abuffer, int pos, int channel); + + class CAudioBuffer { // container for a sound + public: + CAudioBuffer(); + virtual ~CAudioBuffer(); + + static CAudioBuffer* loadWav( QString fileName ); + static CAudioBuffer* loadWav( FILE *wavFile ); // support for stdio + void reallocate( int length ); + + + inline void* getRawData() { return m_data; } + inline int getDataLength() { return m_dataLength; } + + inline int getBytesPerSample() { return (m_bitsPerSample>>3); } + inline int getBitsPerSample() { return m_bitsPerSample; } + inline int getSamplesPerSec() { return m_samplesPerSec; } + inline short getNofChannels() { return m_nofChannels; } + inline SAMPLE_FUNCTION_TYPE getSampleFunction() { return m_sampleFunction; } + + + // static implementations of sample functions + static AUDIO_SAMPLE_TYPE sampleFunction8bitMono( CAudioBuffer *abuffer, int pos, int channel ); + static AUDIO_SAMPLE_TYPE sampleFunction16bitMono( CAudioBuffer *abuffer, int pos, int channel ); + static AUDIO_SAMPLE_TYPE sampleFunction8bitStereo( CAudioBuffer *abuffer, int pos, int channel ); + static AUDIO_SAMPLE_TYPE sampleFunction16bitStereo( CAudioBuffer *abuffer, int pos, int channel ); + + CAudioBufferPlayInstance *playWithMixer( GE::CAudioMixer &mixer ); + + protected: + SAMPLE_FUNCTION_TYPE m_sampleFunction; + short m_nofChannels; + void *m_data; + int m_dataLength; // in bytes + short m_bitsPerSample; + bool m_signedData; + int m_samplesPerSec; + }; + + + + class CAudioBufferPlayInstance : public IAudioSource { + public: + CAudioBufferPlayInstance(); + CAudioBufferPlayInstance( CAudioBuffer *start_playing ); + virtual ~CAudioBufferPlayInstance(); + void playBuffer( CAudioBuffer *startPlaying, float volume, float fixedSpeed, int loopTimes = 0 ); // looptimes -1 = loop forever + + void setSpeed( float speed ); + void setLeftVolume( float lvol ); + void setRightVolume( float rvol ); + + + inline void setLoopTimes( int ltimes ) { m_loopTimes = ltimes; } + void stop(); + + + + int pullAudio( AUDIO_SAMPLE_TYPE *target, int bufferLength ); + bool canBeDestroyed(); + + bool isPlaying() { if (m_buffer) return true; else return false; } + inline bool isFinished() { return m_finished; } + inline bool destroyWhenFinished() { return m_destroyWhenFinished; } + inline void setDestroyWhenFinished( bool set ) { m_destroyWhenFinished = set; } + + protected: + int mixBlock( AUDIO_SAMPLE_TYPE *target, int bufferLength ); + bool m_finished; + bool m_destroyWhenFinished; + int m_fixedPos; + int m_fixedInc; + + int m_fixedLeftVolume; + int m_fixedRightVolume; + int m_fixedCenter; + int m_loopTimes; + CAudioBuffer *m_buffer; + }; + +}; + + + +#endif diff --git a/demos/mobile/quickhit/ga_src/GEAudioOut.cpp b/demos/mobile/quickhit/ga_src/GEAudioOut.cpp new file mode 100644 index 0000000..73a765c --- /dev/null +++ b/demos/mobile/quickhit/ga_src/GEAudioOut.cpp @@ -0,0 +1,144 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtCore/qstring.h> +#include <QAudioOutput> + +#include "GEAudioOut.h" + +using namespace GE; +//using namespace QTM_NAMESPACE; + +/* +#ifndef Q_OS_WIN32 +QTM_USE_NAMESPACE +#endif +*/ + +const int CHANNELS = 2; +const QString CODEC = "audio/pcm"; +const QAudioFormat::Endian BYTEORDER = QAudioFormat::LittleEndian; +const QAudioFormat::SampleType SAMTYPE = QAudioFormat::SignedInt; + + + +AudioOut::AudioOut( QObject *parent, GE::IAudioSource *source ) : QThread(parent) { // qobject + m_source = source; + QAudioFormat format; + format.setFrequency(AUDIO_FREQUENCY); + format.setChannels(CHANNELS); + format.setSampleSize(AUDIO_SAMPLE_BITS); + format.setCodec(CODEC); + format.setByteOrder(BYTEORDER); + format.setSampleType(SAMTYPE); + + QAudioDeviceInfo info(QAudioDeviceInfo::defaultOutputDevice()); + if (!info.isFormatSupported(format)) + format = info.nearestFormat(format); + + + m_audioOutput = new QAudioOutput(info,format); + +#ifdef Q_WS_MAEMO_5 + m_audioOutput->setBufferSize(20000); + m_sendBufferSize = 5000; +#else + m_audioOutput->setBufferSize(16000); + m_sendBufferSize = 4000; +#endif + + m_outTarget = m_audioOutput->start(); + + + m_sendBuffer = new AUDIO_SAMPLE_TYPE[ m_sendBufferSize ]; + m_samplesMixed = 0; + + m_runstate=0; + +#ifndef Q_OS_SYMBIAN + start(); +#else + m_audioOutput->setNotifyInterval(5); + connect(m_audioOutput,SIGNAL(notify()),SLOT(audioNotify())); +#endif + +}; + + +AudioOut::~AudioOut() { + if (m_runstate==0) m_runstate = 1; + if (QThread::isRunning() == false) m_runstate = 2; + while (m_runstate!=2) { msleep(50); } // wait until the thread is finished + m_audioOutput->stop(); + delete m_audioOutput; + delete [] m_sendBuffer; +}; + + +void AudioOut::audioNotify() { + tick(); +}; + +void AudioOut::tick() { + // fill data to buffer as much as free space is available.. + int samplesToWrite = m_audioOutput->bytesFree() / (CHANNELS*AUDIO_SAMPLE_BITS/8); + samplesToWrite*=2; + + if (samplesToWrite > m_sendBufferSize) samplesToWrite = m_sendBufferSize; + if (samplesToWrite<=0) return; + int mixedSamples = m_source->pullAudio( m_sendBuffer, samplesToWrite ); + m_outTarget->write( (char*)m_sendBuffer, mixedSamples*2 ); + +}; + + +void AudioOut::run() { + if (!m_source) { m_runstate=2; return; } + int sleepTime = m_sendBufferSize * 340 / AUDIO_FREQUENCY; + if (sleepTime<2) sleepTime = 2; + + while (m_runstate==0) { + tick(); + msleep(sleepTime); + }; + m_runstate = 2; +}; + + diff --git a/demos/mobile/quickhit/ga_src/GEAudioOut.h b/demos/mobile/quickhit/ga_src/GEAudioOut.h new file mode 100644 index 0000000..dc1f744 --- /dev/null +++ b/demos/mobile/quickhit/ga_src/GEAudioOut.h @@ -0,0 +1,89 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef __GE_QTAUDIOOUT__ +#define __GE_QTAUDIOOUT__ + +#include <QtCore/qobject.h> +#include <QtCore/qfile.h> +#include <QtMultimedia> +#include <QtCore/qtimer.h> +#include <QtCore/qstring.h> +#include <QThread> + +#include "GEInterfaces.h" + + +class QAudioOutput; + +namespace GE { + + + + class AudioOut : public QThread { + Q_OBJECT + + public: + AudioOut(QObject *parent, GE::IAudioSource *source); + virtual ~AudioOut(); + + + + private slots: + void audioNotify(); // for internal notify "solution" + + + protected: + void tick(); + virtual void run(); // this is for the threaded mode only + + + qint64 m_samplesMixed; + + QAudioOutput *m_audioOutput; + QIODevice *m_outTarget; + GE::IAudioSource *m_source; + int m_runstate; + AUDIO_SAMPLE_TYPE *m_sendBuffer; + int m_sendBufferSize; + }; +} + +#endif diff --git a/demos/mobile/quickhit/ga_src/GEInterfaces.cpp b/demos/mobile/quickhit/ga_src/GEInterfaces.cpp new file mode 100644 index 0000000..a71f738 --- /dev/null +++ b/demos/mobile/quickhit/ga_src/GEInterfaces.cpp @@ -0,0 +1,177 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <memory.h> +#include "GEInterfaces.h" + + +using namespace GE; + +/** + * CAudioSource + * common functionality + * + */ +IAudioSource::IAudioSource() { + m_next = 0; +}; + +IAudioSource::~IAudioSource() { + + +}; + +/** + * CAudioMixer + * + */ +CAudioMixer::CAudioMixer() { + m_sourceList = 0; + m_mixingBuffer = 0; + m_mixingBufferLength = 0; + m_fixedGeneralVolume = 4096; +}; + + +CAudioMixer::~CAudioMixer() { + destroyList(); + if (m_mixingBuffer) { + delete [] m_mixingBuffer; + m_mixingBuffer = 0; + }; +}; + +void CAudioMixer::destroyList() { + m_mutex.lock(); + IAudioSource *l = m_sourceList; + while (l) { + IAudioSource *n = l->m_next; + delete l; + l = n; + }; + m_sourceList = 0; + m_mutex.unlock(); +}; + + +IAudioSource* CAudioMixer::addAudioSource( IAudioSource *source ) { + m_mutex.lock(); + source->m_next = 0; + if (m_sourceList) { + IAudioSource *l = m_sourceList; + while (l->m_next) l = l->m_next; + l->m_next = source; + } else m_sourceList = source; + m_mutex.unlock(); + return source; + +}; + + +bool CAudioMixer::removeAudioSource( IAudioSource *source ) { + return true; +}; + +void CAudioMixer::setGeneralVolume( float vol ) { + m_fixedGeneralVolume = (4096.0f*vol); +}; + +int CAudioMixer::pullAudio( AUDIO_SAMPLE_TYPE *target, int bufferLength ) { + + if (!m_sourceList) return 0; + + m_mutex.lock(); + + + if (m_mixingBufferLength<bufferLength) { + if (m_mixingBuffer) delete [] m_mixingBuffer; + m_mixingBufferLength = bufferLength; + m_mixingBuffer = new AUDIO_SAMPLE_TYPE[ m_mixingBufferLength ]; + }; + + memset( target, 0, sizeof( AUDIO_SAMPLE_TYPE ) * bufferLength ); + + AUDIO_SAMPLE_TYPE *t; + AUDIO_SAMPLE_TYPE *t_target; + AUDIO_SAMPLE_TYPE *s; + + IAudioSource *prev = 0; + IAudioSource *l = m_sourceList; + while (l) { + IAudioSource *next = l->m_next; + + // process l + int mixed = l->pullAudio( m_mixingBuffer, bufferLength ); + if (mixed>0) { + // mix to main.. + t = target; + t_target = t+mixed; + s = m_mixingBuffer; + while (t!=t_target) { + *t +=(((*s)*m_fixedGeneralVolume)>>12); + t++; + s++; + }; + }; + + + + // autodestroy + if (l->canBeDestroyed() == true) { // NOTE, IS UNDER TESTING,... MIGHT CAUSE UNPREDICTABLE CRASHING WITH SOME USE CASES!!! + if (!prev) + m_sourceList = next; + else prev->m_next = next; + delete l; + l = 0; + }; + + + + + prev = l; + l = next; + }; + m_mutex.unlock(); + return bufferLength; +}; + + + + diff --git a/demos/mobile/quickhit/ga_src/GEInterfaces.h b/demos/mobile/quickhit/ga_src/GEInterfaces.h new file mode 100644 index 0000000..7abd984 --- /dev/null +++ b/demos/mobile/quickhit/ga_src/GEInterfaces.h @@ -0,0 +1,88 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef __GE_IGA_INTERFACES__ +#define __GE_IGA_INTERFACES__ + +#include <QMutex> + +namespace GE { + +#define AUDIO_FREQUENCY 22050 +#define AUDIO_SAMPLE_TYPE short +#define AUDIO_SAMPLE_BITS 16 + + class IAudioSource { + public: + IAudioSource(); + virtual ~IAudioSource(); + + virtual int pullAudio( AUDIO_SAMPLE_TYPE *target, int bufferLength ) = 0; + virtual bool canBeDestroyed() { return false; } + + IAudioSource *m_next; // for listing, do not touch if you dont know what you are doing. + }; + + + class CAudioMixer : public IAudioSource { + public: + CAudioMixer(); + virtual ~CAudioMixer(); + void destroyList(); // destroy all the sources in the list + + + IAudioSource* addAudioSource( IAudioSource *s ); // add new audio source to the list + bool removeAudioSource( IAudioSource *s ); // remove an audio source from the list + int pullAudio( AUDIO_SAMPLE_TYPE *target, int bufferLength ); + void setGeneralVolume( float vol ); + + + protected: + QMutex m_mutex; + int m_fixedGeneralVolume; + AUDIO_SAMPLE_TYPE *m_mixingBuffer; + int m_mixingBufferLength; + IAudioSource *m_sourceList; + }; + +}; + + +#endif diff --git a/demos/mobile/quickhit/gameengine.cpp b/demos/mobile/quickhit/gameengine.cpp new file mode 100644 index 0000000..99e7d53 --- /dev/null +++ b/demos/mobile/quickhit/gameengine.cpp @@ -0,0 +1,592 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "gameengine.h" +#include "plugins/levelplugininterface.h" +#include "InvSounds.h" + +#include <QDebug> +#include <QTimerEvent> +#include <QTime> +#include <QDesktopServices> + +const int TIMER_SPEED = 80; + +GameEngine::GameEngine(QObject* parent) + :QObject(parent) +{ + m_timerId = 0; + m_doEnemyMissile = 1500 / TIMER_SPEED; + m_GameGml = 0; + m_gameLevel = 0; + + clearQmlObjects(); + + // For random + QTime time = QTime::currentTime(); + qsrand((uint)time.msec()); + + // Sound engine + m_soundEngine = new CInvSounds(this); + + // Device profile + m_silent = false; + +#ifdef Q_OS_SYMBIAN + iVibrate = CHWRMVibra::NewL(); +#endif + + // Get device profile, is it silent? +#if defined Q_OS_SYMBIAN || defined Q_WS_MAEMO_5 + m_systemDeviceInfo = new QSystemDeviceInfo(this); + QObject::connect(m_systemDeviceInfo,SIGNAL(currentProfileChanged(QSystemDeviceInfo::Profile)),this, + SLOT(currentProfileChanged(QSystemDeviceInfo::Profile))); + QSystemDeviceInfo::Profile p = m_systemDeviceInfo->currentProfile(); + if (p == QSystemDeviceInfo::SilentProfile) { + m_silent = true; + } +#endif + +} + + +GameEngine::~GameEngine() +{ +#ifdef Q_OS_SYMBIAN + delete iVibrate; +#endif + +} + +void GameEngine::gameStartSound() +{ + if (!m_silent) + m_soundEngine->gameStartSound(); +} + +#if defined Q_OS_SYMBIAN || defined Q_WS_MAEMO_5 +void GameEngine::currentProfileChanged(QSystemDeviceInfo::Profile p) +{ + if (p == QSystemDeviceInfo::SilentProfile) { + enableSounds(QVariant(false)); + } else { + enableSounds(QVariant(true)); + } +} +#endif + +void GameEngine::enableSounds(QVariant enable) +{ + m_silent = !enable.toBool(); + + if (m_silent) + this->m_soundEngine->enableSounds(false); + else + this->m_soundEngine->enableSounds(true); + +} + +QVariant GameEngine::randInt(QVariant low, QVariant high) +{ + // Random number between low and high + return qrand() % ((high.toInt() + 1) - low.toInt()) + low.toInt(); +} + +void GameEngine::setGameLevel(LevelPluginInterface* level) +{ + // Set used game level + m_gameLevel = level; + + if (m_gameLevel) { + // Set used sound from the level into sound engine + m_soundEngine->enableSounds(m_gameLevel->levelSounds()); + // Invoke QML to take new level in use + QMetaObject::invokeMethod(m_GameGml, "levelReadyForCreation", Qt::AutoConnection); + + m_doEnemyMissile = m_gameLevel->enemyFireSpeed().toInt() / TIMER_SPEED; + } +} + +void GameEngine::setPluginList(QList<QPluginLoader*> plugins) +{ + m_pluginList = plugins; +} + +QVariant GameEngine::pluginList() +{ + QStringList list; + QPluginLoader* loader; + foreach (loader,m_pluginList) { + QString s = loader->fileName(); + s = s.mid(s.lastIndexOf("/")+1); + s = s.left(s.lastIndexOf(".")); + s = s.toUpper(); +#ifdef Q_WS_MAEMO_5 + if (s.contains("LIB")) { + s = s.right(s.length() - (s.indexOf("LIB")+3)); + } +#endif + list.append(s); + } + return QVariant(list); +} + +void GameEngine::pauseLevel(QVariant doPause) +{ + bool enableTimer = !doPause.toBool(); + enableEngineTimer(QVariant(enableTimer)); + QMetaObject::invokeMethod(m_levelQml, "pause", Qt::AutoConnection,Q_ARG(QVariant, doPause)); +} + + +void GameEngine::findQmlObjects() +{ + if (m_GameGml) { + qDebug() << "GameEngine::findQmlObjects()"; + + // Find Missiles objects + m_missileList.clear(); + m_enemyMissileList.clear(); + findMissiles(m_GameGml); + + // Set QMLs + setLevelQml(m_GameGml->findChild<QObject*>("level")); + setEnemiesGridQml(m_GameGml->findChild<QObject*>("enemiesGrid")); + setMyShipQml(m_GameGml->findChild<QObject*>("myShip")); + + // Find Enemies objects + m_enemyList.clear(); + qDebug() << "GameEngine::findQmlObjects() find enemies from: level QML"; + findEnemies(m_levelQml); + + + } else { + qDebug() << "GameEngine::findQmlObjects() rootObject NULL"; + } +} + +void GameEngine::clearQmlObjects() +{ + m_missileList.clear(); + m_enemyMissileList.clear(); + m_enemyList.clear(); + m_levelQml = 0; + m_enemiesGridGml = 0; + m_myShipGml = 0; + //m_GameGml = 0; // NOTE: Do not delete this +} + + +void GameEngine::findMissiles(QObject *rootObject) +{ + if (rootObject) { + QObjectList list = rootObject->children(); + QObject* item; + foreach (item,list) { + if (item->children().count()>0) { + findMissiles(item); + } else { + if (rootObject->objectName()=="missile") { + QDeclarativeItem* missile = static_cast<QDeclarativeItem*>(rootObject); + m_missileList.append(missile); + } else if (rootObject->objectName()=="enemy_missile") { + QDeclarativeItem* enemyMissile = static_cast<QDeclarativeItem*>(rootObject); + m_enemyMissileList.append(enemyMissile); + } + } + } + } else { + qDebug() << "GameEngine::findMissiles() rootObject NULL"; + } +} + +void GameEngine::findEnemies(QObject *rootObject) +{ + if (rootObject) { + QObjectList list = rootObject->children(); + QObject* item; + foreach (item,list) { + if (item->children().count()>0 && item->objectName()!="enemy") { + //qDebug() << "Enemy children found from: " << item->objectName(); + findEnemies(item); + } else { + if (item->objectName()=="enemy") { + //qDebug() << "Enemy child founds: " << item->objectName(); + QDeclarativeItem* enemy = static_cast<QDeclarativeItem*>(item); + m_enemyList.append(enemy); + } + } + } + } else { + qDebug() << "GameEngine::findEnemies() rootObject NULL"; + } +} + +void GameEngine::setEnemiesGridQml(QObject* o) +{ + m_enemiesGridGml = static_cast<QDeclarativeItem*>(o); +} + +void GameEngine::setMyShipQml(QObject* o) +{ + m_myShipGml = static_cast<QDeclarativeItem*>(o); +} + +void GameEngine::setGameQml(QObject* o) +{ + m_GameGml = static_cast<QDeclarativeItem*>(o); +} + + +void GameEngine::timerEvent(QTimerEvent *e) +{ + if (e->timerId()==m_timerId) { + // Do hit test + doHitTest(); + + m_doEnemyMissile--; + + if (m_gameLevel && m_doEnemyMissile<0) { + m_doEnemyMissile = m_gameLevel->enemyFireSpeed().toInt() / TIMER_SPEED; + // Do emeny missile launch + doEnemyMissile(); + } + } +} + +void GameEngine::enableEngineTimer(QVariant enable) +{ + if (m_gameLevel) { + if (m_timerId==0 && enable.toBool()) { + m_timerId = QObject::startTimer(TIMER_SPEED); + } + else if (m_timerId != 0 && !enable.toBool()) { + QObject::killTimer(m_timerId); + m_timerId = 0; + } + } +} + +void GameEngine::selectVisibleEnemy(int& start, int& end) +{ + QDeclarativeItem* enemy = 0; + for (int i=0 ; i<m_enemyList.count() ; i++) { + enemy = m_enemyList[i]; + if (enemy->opacity()==1) { + start = i; + break; + } + } + enemy = 0; + for (int e=m_enemyList.count()-1 ; e>0 ; e--) { + enemy = m_enemyList[e]; + if (enemy->opacity()==1) { + end = e; + break; + } + } +} + +void GameEngine::doEnemyMissile() +{ + QMutexLocker locker(&m_enemyListMutex); + + QDeclarativeItem* missile = 0; + QDeclarativeItem* enemy = 0; + + // Find free missile + foreach (missile, m_enemyMissileList) { + if (missile->opacity()==0){ + // Random select enemy who fire + int start=0; int end=0; + selectVisibleEnemy(start,end); + int whoWillFire = randInt(QVariant(start),QVariant(end)).toInt(); + if (m_enemyList.count() < whoWillFire+1) + break; + + enemy = m_enemyList.at(whoWillFire); + if (enemy && enemy->opacity()==1) { + QPointF enemyP = enemy->pos(); + if (m_enemiesGridGml) { + enemyP += m_enemiesGridGml->pos(); + } + //qDebug() << "QMetaObject::invokeMethod() - fireEnemyMissile"; + QMetaObject::invokeMethod(m_GameGml, "fireEnemyMissile", Qt::AutoConnection, + Q_ARG(QVariant, enemyP.x()+enemy->boundingRect().width()/4), + Q_ARG(QVariant, enemyP.y()+enemy->boundingRect().height()), + Q_ARG(QVariant, m_GameGml->boundingRect().height())); + } + break; + } + } +} + +void GameEngine::doHitTest() +{ + QMutexLocker locker(&m_enemyListMutex); + + QDeclarativeItem* missile = 0; + QDeclarativeItem* enemy = 0; + + // No enemies? + if (m_enemyList.count()==0) { + enableEngineTimer(QVariant(false)); + qDebug() << "No enemies left"; + gameOver(true); + return; + } + + if (!m_myShipGml) { + return; + } + + // Check ship collision + if (m_myShipGml->opacity()==1) { + for (int e=0; e<m_enemyList.count(); e++) { + enemy = m_enemyList[e]; + if (enemy->opacity()==0) { + break; + } + QPointF enemyP = enemy->pos(); + if (m_enemiesGridGml) { + enemyP += m_enemiesGridGml->pos(); + } + QRectF enemyR(enemyP,QSize(enemy->boundingRect().width(),enemy->boundingRect().height())); + // Collision? + if (enemyR.contains(m_myShipGml->pos())) { + enableEngineTimer(QVariant(false)); + + // Collision explosion + QPointF myP = m_myShipGml->pos(); + playSound(1); + QMetaObject::invokeMethod(m_levelQml, "explode", Qt::AutoConnection, + Q_ARG(QVariant, myP.x()+m_myShipGml->boundingRect().width()/2), + Q_ARG(QVariant, myP.y()+m_myShipGml->boundingRect().height())); + m_myShipGml->setOpacity(0); + + gameOver(false); + qDebug() << "Collision"; + return; + } + // Enemy too deep? + else if (enemyR.bottomLeft().y() > m_myShipGml->pos().y()+m_myShipGml->pos().y()*0.1) { + enableEngineTimer(QVariant(false)); + + // Enemy too deep explosion + QPointF myP = m_myShipGml->pos(); + playSound(1); + QMetaObject::invokeMethod(m_levelQml, "explode", Qt::AutoConnection, + Q_ARG(QVariant, myP.x()+m_myShipGml->boundingRect().width()/2), + Q_ARG(QVariant, myP.y()+m_myShipGml->boundingRect().height())); + m_myShipGml->setOpacity(0); + + gameOver(false); + qDebug() << "Enemy too deep"; + return; + } + } + } + + // Check your missiles hit to enemies + foreach (missile, m_missileList) { + if (missile->opacity()==1){ + for (int e=0; e<m_enemyList.count(); e++) { + enemy = m_enemyList[e]; + if (enemy->opacity()<1) { + break; + } + QPointF missileP = missile->pos(); + missileP.setX(missileP.rx() + missile->boundingRect().width()/2); + + QPointF enemyP = enemy->pos(); + if (m_enemiesGridGml) { + enemyP += m_enemiesGridGml->pos(); + } + + QRectF r(enemyP,QSize(enemy->boundingRect().width(),enemy->boundingRect().height())); + if (r.contains(missileP)) { + // Hit ! + playSound(0); + //qDebug() << "QMetaObject::invokeMethod() - explode"; + QMetaObject::invokeMethod(m_levelQml, "explode", Qt::AutoConnection, + Q_ARG(QVariant, enemyP.x()+enemy->boundingRect().width()/2), + Q_ARG(QVariant, enemyP.y()+enemy->boundingRect().height())); + missile->setOpacity(0); + //fastVibra(); + if (m_enemiesGridGml) { + // Set transparent placeholder for enemy when using GridView + enemy->setProperty("source",QVariant("file:/"+m_gameLevel->pathToTransparentEnemyPic().toString())); + } else { + // Hide enemy after explode + enemy->setOpacity(0); + } + + // Remove enemy from list + m_enemyList.removeAt(e); + e--; + } + enemy = 0; + } + } + } + + // Check enemies missiles hit to you + if (m_myShipGml->opacity()==1) { + foreach (missile, m_enemyMissileList) { + if (missile->opacity()==1){ + QPointF missileP = missile->pos(); + missileP.setX(missileP.rx() + missile->boundingRect().width()/2); + + QPointF myP = m_myShipGml->pos(); + + QRectF r(myP,QSize(m_myShipGml->boundingRect().width(),m_myShipGml->boundingRect().height())); + if (r.contains(missileP)) { + // Hit ! + playSound(1); + //qDebug() << "QMetaObject::invokeMethod() - explode"; + QMetaObject::invokeMethod(m_levelQml, "explode", Qt::AutoConnection, + Q_ARG(QVariant, myP.x()+m_myShipGml->boundingRect().width()/2), + Q_ARG(QVariant, myP.y()+m_myShipGml->boundingRect().height())); + missile->setOpacity(0); + m_myShipGml->setOpacity(0); + break; + } + } + } + } else { + // You was killed + enableEngineTimer(QVariant(false)); + gameOver(false); + qDebug() << "You was killed by enemy missile"; + } + +} + + +void GameEngine::playSound(QVariant index) +{ + if (!m_silent) { + int i = index.toInt(); + m_soundEngine->playSound(i); + } +} + +void GameEngine::playSounds(QVariant index, QVariant count) +{ + if (!m_silent) { + m_soundEngine->playSounds(index.toInt(),count.toInt()); + } +} + +void GameEngine::playInternalSound(QVariant index) +{ + if (!m_silent) { + m_soundEngine->playInternalSound(index.toInt()); + } +} + +void GameEngine::playInternalSounds(QVariant index, QVariant count) +{ + if (!m_silent) { + m_soundEngine->playInternalSounds(index.toInt(),count.toInt()); + } +} + +void GameEngine::gameOver(bool youWin) +{ + qDebug() << "GameEngine::gameOver() "<< youWin; + QMetaObject::invokeMethod(m_GameGml, "gameOver", Qt::AutoConnection,Q_ARG(QVariant, youWin)); +} + +void GameEngine::pauseGame() { + QMetaObject::invokeMethod(m_GameGml, "pauseGame", Qt::AutoConnection); +} + + +QVariant GameEngine::isSymbian() +{ +#ifdef Q_OS_SYMBIAN + return QVariant(true); +#else + return QVariant(false); +#endif +} + +QVariant GameEngine::isMaemo() +{ +#ifdef Q_WS_MAEMO_5 + return QVariant(true); +#else + return QVariant(false); +#endif +} + +QVariant GameEngine::isWindows() +{ +#ifdef Q_OS_WIN + return QVariant(true); +#else + return QVariant(false); +#endif +} + +void GameEngine::vibra() +{ +#ifdef Q_OS_SYMBIAN + if (iVibrate){ + TRAPD(err, iVibrate->StartVibraL(4000,KHWRMVibraMaxIntensity)); + } +#endif +} + +void GameEngine::fastVibra() +{ +#ifdef Q_OS_SYMBIAN + if (iVibrate){ + TRAPD(err, iVibrate->StartVibraL(100,KHWRMVibraMaxIntensity)); + } +#endif +} + +void GameEngine::openLink(QVariant link) +{ +QDesktopServices::openUrl(QUrl(link.toString())); +} + diff --git a/demos/mobile/quickhit/gameengine.h b/demos/mobile/quickhit/gameengine.h new file mode 100644 index 0000000..c8c8b8c --- /dev/null +++ b/demos/mobile/quickhit/gameengine.h @@ -0,0 +1,148 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef GAMEENGINE_H +#define GAMEENGINE_H + +#include <QObject> +#include <QDeclarativeItem> +#include <QMutex> +#include <QPluginLoader> +#include <QList> + +#ifdef Q_OS_SYMBIAN +#include <hwrmvibra.h> +#endif + +// QtMobility +#if defined Q_OS_SYMBIAN || defined Q_WS_MAEMO_5 +#include <QSystemDeviceInfo> +QTM_USE_NAMESPACE +#endif + +class CInvSounds; +class LevelPluginInterface; +class GameEngine : public QObject +{ + Q_OBJECT + +public: + GameEngine(QObject* parent); + ~GameEngine(); + void timerEvent(QTimerEvent *); + void setGameLevel(LevelPluginInterface* level); + void setPluginList(QList<QPluginLoader*> plugins); + void pauseGame(); + +public: + Q_INVOKABLE void enableEngineTimer(QVariant enable); + Q_INVOKABLE QVariant randInt(QVariant low, QVariant high); + Q_INVOKABLE void enableSounds(QVariant enable); + Q_INVOKABLE void playSound(QVariant index); + Q_INVOKABLE void playSounds(QVariant index, QVariant count); + Q_INVOKABLE void playInternalSound(QVariant index); + Q_INVOKABLE void playInternalSounds(QVariant index, QVariant count); + Q_INVOKABLE QVariant pluginList(); + Q_INVOKABLE void findQmlObjects(); + Q_INVOKABLE void clearQmlObjects(); + Q_INVOKABLE void pauseLevel(QVariant doPause); + Q_INVOKABLE void gameStartSound(); + + Q_INVOKABLE QVariant isSymbian(); + Q_INVOKABLE QVariant isMaemo(); + Q_INVOKABLE QVariant isWindows(); + + Q_INVOKABLE void vibra(); + Q_INVOKABLE void fastVibra(); + + Q_INVOKABLE void openLink(QVariant link); + + +private slots: +#if defined Q_OS_SYMBIAN || defined Q_WS_MAEMO_5 + void currentProfileChanged (QSystemDeviceInfo::Profile); +#endif + +public: + void setGameQml(QObject* o); + +private: + void findMissiles(QObject* rootObject); + void findEnemies(QObject* rootObject); + void setLevelQml(QObject* o) {m_levelQml = o;} + void setEnemiesGridQml(QObject* o); + void setMyShipQml(QObject* o); + void gameOver(bool youWin); + void selectVisibleEnemy(int& start, int& end); + +private: + void doHitTest(); + void doEnemyMissile(); + +private: + bool m_enableEnemyMissiles; + QMutex m_enemyListMutex; + QList<QDeclarativeItem*> m_enemyList; + QList<QDeclarativeItem*> m_missileList; + QList<QDeclarativeItem*> m_enemyMissileList; + QObject* m_levelQml; + QDeclarativeItem* m_enemiesGridGml; + QDeclarativeItem* m_myShipGml; + QDeclarativeItem* m_GameGml; + + LevelPluginInterface* m_gameLevel; + CInvSounds* m_soundEngine; + QList<QPluginLoader*> m_pluginList; + + int m_timerId; + int m_doEnemyMissile; + +#if defined Q_OS_SYMBIAN || defined Q_WS_MAEMO_5 + QSystemDeviceInfo* m_systemDeviceInfo; +#endif + bool m_silent; + +#ifdef Q_OS_SYMBIAN + CHWRMVibra* iVibrate; +#endif + +}; + +#endif // GAMEENGINE_H diff --git a/demos/mobile/quickhit/gfx/back.png b/demos/mobile/quickhit/gfx/back.png Binary files differnew file mode 100644 index 0000000..bb66f74 --- /dev/null +++ b/demos/mobile/quickhit/gfx/back.png diff --git a/demos/mobile/quickhit/gfx/background2.png b/demos/mobile/quickhit/gfx/background2.png Binary files differnew file mode 100644 index 0000000..c81875a --- /dev/null +++ b/demos/mobile/quickhit/gfx/background2.png diff --git a/demos/mobile/quickhit/gfx/bigship.png b/demos/mobile/quickhit/gfx/bigship.png Binary files differnew file mode 100644 index 0000000..b88dc32 --- /dev/null +++ b/demos/mobile/quickhit/gfx/bigship.png diff --git a/demos/mobile/quickhit/gfx/exit.png b/demos/mobile/quickhit/gfx/exit.png Binary files differnew file mode 100644 index 0000000..a45abd6 --- /dev/null +++ b/demos/mobile/quickhit/gfx/exit.png diff --git a/demos/mobile/quickhit/gfx/pause.png b/demos/mobile/quickhit/gfx/pause.png Binary files differnew file mode 100644 index 0000000..0570908 --- /dev/null +++ b/demos/mobile/quickhit/gfx/pause.png diff --git a/demos/mobile/quickhit/gfx/quickhit_logo.png b/demos/mobile/quickhit/gfx/quickhit_logo.png Binary files differnew file mode 100644 index 0000000..0b505c7 --- /dev/null +++ b/demos/mobile/quickhit/gfx/quickhit_logo.png diff --git a/demos/mobile/quickhit/gfx/soundOff.png b/demos/mobile/quickhit/gfx/soundOff.png Binary files differnew file mode 100644 index 0000000..fed8520 --- /dev/null +++ b/demos/mobile/quickhit/gfx/soundOff.png diff --git a/demos/mobile/quickhit/gfx/soundOn.png b/demos/mobile/quickhit/gfx/soundOn.png Binary files differnew file mode 100644 index 0000000..03bd80e --- /dev/null +++ b/demos/mobile/quickhit/gfx/soundOn.png diff --git a/demos/mobile/quickhit/icon.svg b/demos/mobile/quickhit/icon.svg new file mode 100644 index 0000000..3795e8d --- /dev/null +++ b/demos/mobile/quickhit/icon.svg @@ -0,0 +1,305 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!-- Created with Inkscape (http://www.inkscape.org/) --> + +<svg + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:cc="http://creativecommons.org/ns#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + xmlns:xlink="http://www.w3.org/1999/xlink" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + width="128" + height="128" + id="svg2" + version="1.1" + inkscape:version="0.48.0 r9654" + sodipodi:docname="New document 1"> + <defs + id="defs4" /> + <sodipodi:namedview + id="base" + pagecolor="#ffffff" + bordercolor="#666666" + borderopacity="1.0" + inkscape:pageopacity="0.0" + inkscape:pageshadow="2" + inkscape:zoom="2.8" + inkscape:cx="151.3239" + inkscape:cy="33.99485" + inkscape:document-units="px" + inkscape:current-layer="layer1" + showgrid="false" + inkscape:window-width="1680" + inkscape:window-height="1003" + inkscape:window-x="-4" + inkscape:window-y="-4" + inkscape:window-maximized="1" /> + <metadata + id="metadata7"> + <rdf:RDF> + <cc:Work + rdf:about=""> + <dc:format>image/svg+xml</dc:format> + <dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> + <dc:title></dc:title> + </cc:Work> + </rdf:RDF> + </metadata> + <g + inkscape:label="Layer 1" + inkscape:groupmode="layer" + id="layer1" + transform="translate(0,-924.36218)"> + <image + y="924.6955" + x="-0.20219566" + id="image2993" + xlink:href="data:image/png;base64,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 +" + height="128" + width="128" /> + </g> +</svg> diff --git a/demos/mobile/quickhit/main.cpp b/demos/mobile/quickhit/main.cpp new file mode 100644 index 0000000..e2eb8cf2 --- /dev/null +++ b/demos/mobile/quickhit/main.cpp @@ -0,0 +1,101 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtGui/QApplication> +#include <QDesktopWidget> +#include "mainwindow.h" + +// Lock S60 orientation +#ifdef Q_OS_SYMBIAN +#include <eikenv.h> +#include <eikappui.h> +#include <aknenv.h> +#include <aknappui.h> +#endif + +#ifndef QT_NO_OPENGL + #include <QGLWidget> +#endif + + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + + // Lock S60 orientation +#ifdef Q_OS_SYMBIAN + CAknAppUi* appUi = dynamic_cast<CAknAppUi*> (CEikonEnv::Static()->AppUi()); + TRAPD(error, + if (appUi) { + appUi->SetOrientationL(CAknAppUi::EAppUiOrientationPortrait); + } + ); +#endif + + MainWindow w; + +#ifndef QT_NO_OPENGL + // Use QGLWidget to get the opengl support if available + QGLFormat format = QGLFormat::defaultFormat(); + format.setSampleBuffers(false); + + QGLWidget *glWidget = new QGLWidget(format); + glWidget->setAutoFillBackground(false); + w.setViewport(glWidget); // ownership of glWidget is taken +#endif + + QObject *rootObject = dynamic_cast<QObject*>(w.rootObject()); + + // For Qt.exit() from QML + QObject::connect((QObject*)w.engine(), SIGNAL(quit()), &a, SLOT(quit())); + // Level activation signal from QML + QObject::connect(rootObject, SIGNAL(levelActivated(int)), &w, SLOT(levelActivated(int))); + +#if defined (Q_OS_SYMBIAN) || defined (Q_WS_MAEMO_5) + w.setGeometry(QApplication::desktop()->screenGeometry()); + w.showFullScreen(); +#else + w.setGeometry(100,100,360,640); + w.setFixedSize(360,640); + w.show(); +#endif + + return a.exec(); +} diff --git a/demos/mobile/quickhit/mainwindow.cpp b/demos/mobile/quickhit/mainwindow.cpp new file mode 100644 index 0000000..51c440b --- /dev/null +++ b/demos/mobile/quickhit/mainwindow.cpp @@ -0,0 +1,248 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "mainwindow.h" +#include "gameengine.h" +#include "plugins/levelplugininterface.h" + +#include <QDebug> +#include <QDir> +#include <QMessageBox> +#include <QLibraryInfo> +#include <QDeclarativeEngine> +#include <QDesktopWidget> + +MainWindow::MainWindow(QWidget *parent) + : QDeclarativeView(parent) +{ + +#ifdef Q_WS_MAEMO_5 + window()->setAttribute(Qt::WA_Maemo5PortraitOrientation, true); +#endif + + // Game engine + m_gameEngine = new GameEngine(this); + + // Load all levels plugins + m_levelPlugin = 0; + loadLevelPlugins(); + + // QML main window + engine()->addImportPath("./imports"); + setResizeMode(QDeclarativeView::SizeRootObjectToView); + + // Set game engine visible to QML + rootContext()->setContextProperty("GameEngine", m_gameEngine); + + // Set QML source + setSource(QUrl("qrc:/Game.qml")); + //setSource(QUrl("../QuickHit/Game.qml")); + + // Store QML root object for game engine + QObject *ro = static_cast<QObject*>(rootObject()); + m_gameEngine->setGameQml(ro); + m_gameEngine->findQmlObjects(); + + // Application foreground / background event filter for filterin incoming call (window) + // when game will be paused + m_eventFilter = new MyEventFilter(this); + QObject::connect(m_eventFilter,SIGNAL(activationChangeFiltered()),this,SLOT(activationChangeFiltered())); + qApp->installEventFilter(m_eventFilter); + + // Remove context menu from the all widgets + QWidgetList widgets = QApplication::allWidgets(); + QWidget* w = 0; + foreach (w,widgets){ + w->setContextMenuPolicy(Qt::NoContextMenu); + } +} + +MainWindow::~MainWindow() +{ + for (int i=0;i<m_plugins.count();i++) { + m_plugins[i]->unload(); + } + m_plugins.clear(); + +} + +void MainWindow::activationChangeFiltered() +{ + m_gameEngine->pauseGame(); +} + +void MainWindow::levelActivated(int index) +{ + // Set level for the game engine + createPlugin(index); + rootContext()->setContextProperty("LevelPlugin", m_levelPlugin); + m_gameEngine->setGameLevel(m_levelPlugin); +} + +void MainWindow::loadLevelPlugins() +{ +#if defined (Q_OS_SYMBIAN) + bool exists_c = loadPlugins("c", "quickhitlevels"); + bool exists_e = loadPlugins("e", "quickhitlevels"); + bool exists_f = loadPlugins("f", "quickhitlevels"); + if (exists_c || exists_e || exists_f) { + m_gameEngine->setPluginList(m_plugins); + createPlugin(); + } + else { + //QMessageBox::information(this, "QuickHit", "Could not load any of the quickhitlevels"); + } +#else + if (loadPlugins("c", "quickhitlevels")) { + m_gameEngine->setPluginList(m_plugins); + createPlugin(); + } + else { + //QMessageBox::information(this, "QuickHit", "Could not load any of the quickhitlevels"); + } + + +#endif +} + +bool MainWindow::loadPlugins(QString drive, QString pluginDir) +{ +#if defined (Q_OS_SYMBIAN) + QDir pluginsDir(drive + ":" + QLibraryInfo::location(QLibraryInfo::PluginsPath)); +#elif defined Q_OS_WIN32 + QDir pluginsDir = QDir::currentPath(); +#else + QDir pluginsDir(QLibraryInfo::location(QLibraryInfo::PluginsPath)); +#endif + pluginsDir.cd(pluginDir); + + qDebug() << "Loads plugins from : " << pluginsDir.path(); + + bool newPluginsLoaded = false; + + foreach (QString fileName, pluginsDir.entryList(QDir::Files)) + { + // Accept only plugin files +#if defined (Q_OS_SYMBIAN) + if (fileName.contains(".qtplugin",Qt::CaseInsensitive)) { +#elif defined (Q_WS_MAEMO_5) + if (fileName.contains(".so",Qt::CaseInsensitive)) { +#else + if (fileName.contains(".dll",Qt::CaseInsensitive)) { +#endif + + // Create plugin loader + QPluginLoader* pluginLoader = new QPluginLoader(pluginsDir.absoluteFilePath(fileName)); + // Load plugin + bool ret = pluginLoader->load(); + if (!ret) { + // Loading failed + qDebug() << "Could not load plugin " << fileName; + } else { + // Loading done + // Test creating plugin + QObject *plugin = 0; + LevelPluginInterface* pluginIF = 0; + plugin = pluginLoader->instance(); + pluginIF = qobject_cast<LevelPluginInterface*> (plugin); + if (pluginIF) { + qDebug() << "Plugin can be created"; + // Store loader to array + m_plugins.append(pluginLoader); + newPluginsLoaded = true; + } else { + pluginLoader->unload(); + qDebug() << "Plugin can NOT be created!"; + } + } + } + } + + return newPluginsLoaded; +} + + +void MainWindow::createPlugin(int index) +{ + if (index == -1) { + return; + } + + m_levelPlugin = 0; + + // Try to create plugin instance + QPluginLoader* pluginLoader = m_plugins[index]; + QObject *plugin = pluginLoader->instance(); + if (plugin) { + // Plugin instance created + // Cast plugin to LevelPluginInterface, that is common for all plugins + LevelPluginInterface* pluginIF = qobject_cast<LevelPluginInterface*> (plugin); + m_levelPlugin = pluginIF; + qDebug() << "Plugin created: " << index; + } + else { + qDebug() << "Creating plugin failed!"; + QMessageBox::information(this, "QuickHit", "Could not create quickhitlevels"); + } +} + +void MainWindow::printObjectTree(QObject* parent) +{ + if (parent) { + qDebug() << "className:" << parent->metaObject()->className(); + qDebug() << "objectName:" << parent->objectName(); + + QObjectList list = parent->children(); + QObject* item; + foreach (item,list) { + if (item->children().count()>0) { + qDebug() << "--Childrens found--"; + printObjectTree(item); + } else { + qDebug() << "className:" << item->metaObject()->className(); + qDebug() << "objectName:" << item->objectName(); + } + } + } else { + qDebug() << "object NULL"; + } + +} + diff --git a/demos/mobile/quickhit/mainwindow.h b/demos/mobile/quickhit/mainwindow.h new file mode 100644 index 0000000..69846ef --- /dev/null +++ b/demos/mobile/quickhit/mainwindow.h @@ -0,0 +1,85 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef MAINWINDOW_H +#define MAINWINDOW_H + +#include <QtGui/QMainWindow> +#include <QDeclarativeView> + +#include <QApplication> +#include <QDeclarativeView> +#include <QDeclarativeContext> +#include <QGraphicsObject> +#include <QMouseEvent> +#include <QPluginLoader> + +#include "myeventfilter.h" + +class GameEngine; +class LevelPluginInterface; + +class MainWindow : public QDeclarativeView +{ + Q_OBJECT + +public: + MainWindow(QWidget *parent = 0); + ~MainWindow(); + +public slots: + void levelActivated(int); + void activationChangeFiltered(); + +private: + void printObjectTree(QObject* parent); + void loadLevelPlugins(); + bool loadPlugins(QString drive, QString pluginDir); + void createPlugin(int index = -1); + +private: + GameEngine* m_gameEngine; + LevelPluginInterface* m_levelPlugin; + QList<QPluginLoader*> m_plugins; + + MyEventFilter* m_eventFilter; +}; + +#endif // MAINWINDOW_H diff --git a/demos/mobile/quickhit/myeventfilter.cpp b/demos/mobile/quickhit/myeventfilter.cpp new file mode 100644 index 0000000..6ff8890 --- /dev/null +++ b/demos/mobile/quickhit/myeventfilter.cpp @@ -0,0 +1,67 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QDebug> +#include "myeventfilter.h" + +MyEventFilter::MyEventFilter(QObject *parent) : + QObject(parent) +{ +} + +MyEventFilter::~MyEventFilter() +{ +} + +bool MyEventFilter::eventFilter(QObject *obj, QEvent *event) +{ + // http://doc.trolltech.com/4.7/qevent.html#QEvent + + // QEvent::ActivationChange : The application has been made available to the user. + + if (event->type() == QEvent::ActivationChange) { + emit activationChangeFiltered(); + qDebug() << "ActivationChangeFiltered()"; + return false; + } else { + // standard event processing + return QObject::eventFilter(obj, event); + } +} diff --git a/demos/mobile/quickhit/myeventfilter.h b/demos/mobile/quickhit/myeventfilter.h new file mode 100644 index 0000000..279cd26 --- /dev/null +++ b/demos/mobile/quickhit/myeventfilter.h @@ -0,0 +1,63 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef KEYEVENTLISTENER_H +#define KEYEVENTLISTENER_H + +#include <QObject> +#include <QKeyEvent> + +class MyEventFilter : public QObject +{ + Q_OBJECT + +public: + MyEventFilter(QObject *parent = 0); + ~MyEventFilter(); + +protected: + bool eventFilter(QObject *obj, QEvent *event); + +signals: + void activationChangeFiltered(); + +}; + +#endif // KEYEVENTLISTENER_H diff --git a/demos/mobile/quickhit/plugins/LevelOne/Level.qml b/demos/mobile/quickhit/plugins/LevelOne/Level.qml new file mode 100644 index 0000000..d564e6e --- /dev/null +++ b/demos/mobile/quickhit/plugins/LevelOne/Level.qml @@ -0,0 +1,214 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 1.0 +import Qt.labs.particles 1.0 + +Rectangle { + id: enemies + anchors.fill: parent + color: "black" + + + // Background image for the level + Image { + id: background1 + source: "file:/"+LevelPlugin.pictureRootPath()+"background3.png" + fillMode: Image.PreserveAspectCrop + smooth: true + //anchors.fill: parent + width: parent.width + height: parent.height + } + + + // *************************************************** + // *** NOTE: This is mandatory for all level QML files + function pause(doPause) { + if (doPause) { + rightLeftAnim.pause() + upToDownAnim.pause() + } else { + rightLeftAnim.resume() + upToDownAnim.resume() + } + } + + + // *************************************************** + // *** NOTE: This is mandatory for all level QML files + objectName: "level" + + property int enemySpeed: LevelPlugin.enemySpeed() + property int enemyMaxWidth + + // Create enemies dynamically + function createEnemies(amount) { + var b = false; + for (var i=0;i<amount;i++) { + if (b){ + Qt.createQmlObject('import QtQuick 1.0; Image { property bool hit:false; width:50; objectName:"enemy"; smooth:true; fillMode:Image.PreserveAspectFit; source:"file:/"+LevelPlugin.pictureRootPath()+"enemy1.png";}',enemiesGrid); + } else { + Qt.createQmlObject('import QtQuick 1.0; Image { property bool hit:false; width:50; objectName:"enemy"; smooth:true; fillMode:Image.PreserveAspectFit; source:"file:/"+LevelPlugin.pictureRootPath()+"enemy2.png";}',enemiesGrid); + } + b = !b; + } + } + + // Calculate enemy max width + function calEnemyMaxWidth() { + var enemyCountInCol = LevelPlugin.enemyCount() / LevelPlugin.enemyRowCount(); + enemyCountInCol++; // add some extra space needs for width + if (enemyCountInCol*LevelPlugin.graphSize(LevelPlugin.pictureRootPath()+"enemy1.png").width > gameArea.width) { + enemyMaxWidth = gameArea.width / (enemyCountInCol + 1); + } + else { + enemyMaxWidth = LevelPlugin.graphSize(LevelPlugin.pictureRootPath()+"enemy1.png").width; + } + } + + + Component.onCompleted: { + // Calculate enemy max width + calEnemyMaxWidth() + + // Create enemies dynamically after component created + createEnemies(LevelPlugin.enemyCount()) + + // Start animations + enemiesGrid.y = enemiesGrid.height * -1 + rightLeftAnim.restart() + upToDownAnim.restart() + + // Flying stars animation, not in Maemo + if (!GameEngine.isMaemo()) { + starBurstTimer.restart() + } + + GameEngine.playSound(4) // NOTE: Level start sound + } + + + Timer { + id: starBurstTimer + interval: starParticles.lifeSpan+GameEngine.randInt(100,2000); running: false; repeat: true + onTriggered: { + starParticles.burst(GameEngine.randInt(4,10)) + } + } + + + // Right-left animation + SequentialAnimation { + id: rightLeftAnim + loops: Animation.Infinite + NumberAnimation { target:enemiesGrid; property:"x"; from: 0; to:gameArea.width - enemiesGrid.width; easing.type: Easing.OutQuad; duration: 3000 } + NumberAnimation { target:enemiesGrid; property:"x"; to: 0; easing.type: Easing.OutQuad; duration: 3000 } + } + + // Up to down animation + PropertyAnimation { id: upToDownAnim; target:enemiesGrid; property:"y"; to: gameArea.height; + easing.type: Easing.Linear; duration: enemies.enemySpeed } + + Grid { + id: enemiesGrid + objectName: "enemiesGrid" + columns: LevelPlugin.enemyCount() / LevelPlugin.enemyRowCount() + spacing: 8 + } + + // *************************************************** + // *** NOTE: This is mandatory for all level QML files + // Execute explode particle effect + function explode(x,y) { + explodeParticles.x = x + explodeParticles.y = y + explodeParticles.burst(20) + explodeParticles.opacity = 1 + } + // *************************************************** + // *** NOTE: This is mandatory for all level QML files + // Explode particle effect + Particles { + id: explodeParticles + opacity: 0 + width: 1 + height: 1 + emissionRate: 0 + source: "file:/"+LevelPlugin.pictureRootPath()+"red_fire.png" + lifeSpan: 500 + lifeSpanDeviation: 2000 + count: -1 + angle: 270 + angleDeviation: 65 + velocity: 100 + velocityDeviation: 100 + ParticleMotionGravity { + yattractor: 1000 + xattractor: 300 + acceleration: 50 + } + } + + Particles { + id: starParticles + y: -50 + x: 0 + width: parent.width + height: 50 + emissionRate: 0 + source: "file:/"+LevelPlugin.pictureRootPath()+"star3.png" + lifeSpan: 3000 + count: -1 + angle: 90 + velocity: 100 + ParticleMotionGravity { + yattractor: 1000 + xattractor: 500 + } + } + + +} + + + + + diff --git a/demos/mobile/quickhit/plugins/LevelOne/debian/changelog b/demos/mobile/quickhit/plugins/LevelOne/debian/changelog new file mode 100644 index 0000000..de7ac98 --- /dev/null +++ b/demos/mobile/quickhit/plugins/LevelOne/debian/changelog @@ -0,0 +1,11 @@ +levelone (1.1.0) unstable; urgency=low + + * Final graphics + + -- Antonio Aloisio <antonio.aloisio@nokia.com> Wed, 5 Jan 2011 10:05:04 +0200 + +levelone (1.0.0) unstable; urgency=low + + * First version + + -- Antonio Aloisio <antonio.aloisio@nokia.com> Tue, 19 Oct 2010 10:05:04 +0200 diff --git a/demos/mobile/quickhit/plugins/LevelOne/debian/compat b/demos/mobile/quickhit/plugins/LevelOne/debian/compat new file mode 100644 index 0000000..7f8f011 --- /dev/null +++ b/demos/mobile/quickhit/plugins/LevelOne/debian/compat @@ -0,0 +1 @@ +7 diff --git a/demos/mobile/quickhit/plugins/LevelOne/debian/control b/demos/mobile/quickhit/plugins/LevelOne/debian/control new file mode 100644 index 0000000..c46afef --- /dev/null +++ b/demos/mobile/quickhit/plugins/LevelOne/debian/control @@ -0,0 +1,11 @@ +Source: levelone +Section: user/games +Priority: extra +Maintainer: Antonio Aloisio <antonio.aloisio@nokia.com> +Standards-Version: 3.7.2 + +Package: levelone +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends} +Description: QuickHit - LevelOne + QuickHit - LevelOne diff --git a/demos/mobile/quickhit/plugins/LevelOne/debian/copyright b/demos/mobile/quickhit/plugins/LevelOne/debian/copyright new file mode 100644 index 0000000..fb9e5a8 --- /dev/null +++ b/demos/mobile/quickhit/plugins/LevelOne/debian/copyright @@ -0,0 +1,8 @@ +This is qmultiwinexample, written and maintained by Forum Nokia Antonio Aloisio <antonio.aloisio@nokia.com> +on Tue, 19 Oct 2010 10:05:04 +0200 + + +Copyright Holder: Nokia (c) 2010 + +License: + diff --git a/demos/mobile/quickhit/plugins/LevelOne/debian/dirs b/demos/mobile/quickhit/plugins/LevelOne/debian/dirs new file mode 100644 index 0000000..80507f1 --- /dev/null +++ b/demos/mobile/quickhit/plugins/LevelOne/debian/dirs @@ -0,0 +1,2 @@ +usr/bin +usr/share/applications/hildon diff --git a/demos/mobile/quickhit/plugins/LevelOne/debian/postinst b/demos/mobile/quickhit/plugins/LevelOne/debian/postinst new file mode 100644 index 0000000..79fb6dd --- /dev/null +++ b/demos/mobile/quickhit/plugins/LevelOne/debian/postinst @@ -0,0 +1,5 @@ +#!/bin/sh -e + +gtk-update-icon-cache -f /usr/share/icons/hicolor + +exit 0 diff --git a/demos/mobile/quickhit/plugins/LevelOne/debian/rules b/demos/mobile/quickhit/plugins/LevelOne/debian/rules new file mode 100644 index 0000000..53a1d2e --- /dev/null +++ b/demos/mobile/quickhit/plugins/LevelOne/debian/rules @@ -0,0 +1,91 @@ +#!/usr/bin/make -f +# -*- makefile -*- +# Sample debian/rules that uses debhelper. +# This file was originally written by Joey Hess and Craig Small. +# As a special exception, when this file is copied by dh-make into a +# dh-make output file, you may use that output file without restriction. +# This special exception was added by Craig Small in version 0.37 of dh-make. + +# Uncomment this to turn on verbose mode. +#export DH_VERBOSE=1 + + +APPNAME := levelone + + +configure: configure-stamp +configure-stamp: + dh_testdir + # Add here commands to configure the package. + + touch configure-stamp + + +build: build-stamp + +build-stamp: configure-stamp + dh_testdir + + # Add here commands to compile the package. + $(MAKE) + #docbook-to-man debian/$(APPNAME).sgml > $(APPNAME).1 + + touch $@ + +clean: + dh_testdir + dh_testroot + rm -f build-stamp configure-stamp + + # Add here commands to clean up after the build process. + $(MAKE) clean + + dh_clean + +install: build + dh_testdir + dh_testroot + dh_clean -k + dh_installdirs + + # Add here commands to install the package into debian/$(APPNAME). + $(MAKE) INSTALL_ROOT="$(CURDIR)"/debian/$(APPNAME) install + + +# Build architecture-independent files here. +binary-indep: build install +# We have nothing to do by default. + +# Build architecture-dependent files here. +binary-arch: build install + dh_testdir + dh_testroot + dh_installchangelogs + dh_installdocs + dh_installexamples +# dh_install +# dh_installmenu +# dh_installdebconf +# dh_installlogrotate +# dh_installemacsen +# dh_installpam +# dh_installmime +# dh_python +# dh_installinit +# dh_installcron +# dh_installinfo + dh_installman + dh_link + # dh_strip + dh_compress + dh_fixperms +# dh_perl + dh_makeshlibs + dh_installdeb + dh_shlibdeps + dh_gencontrol + dh_md5sums + dh_builddeb + +binary: binary-indep binary-arch +.PHONY: build clean binary-indep binary-arch binary install configure diff --git a/demos/mobile/quickhit/plugins/LevelOne/gfx/background3.png b/demos/mobile/quickhit/plugins/LevelOne/gfx/background3.png Binary files differnew file mode 100644 index 0000000..c81875a --- /dev/null +++ b/demos/mobile/quickhit/plugins/LevelOne/gfx/background3.png diff --git a/demos/mobile/quickhit/plugins/LevelOne/gfx/enemy1.png b/demos/mobile/quickhit/plugins/LevelOne/gfx/enemy1.png Binary files differnew file mode 100644 index 0000000..94f149b --- /dev/null +++ b/demos/mobile/quickhit/plugins/LevelOne/gfx/enemy1.png diff --git a/demos/mobile/quickhit/plugins/LevelOne/gfx/enemy2.png b/demos/mobile/quickhit/plugins/LevelOne/gfx/enemy2.png Binary files differnew file mode 100644 index 0000000..448f8ca --- /dev/null +++ b/demos/mobile/quickhit/plugins/LevelOne/gfx/enemy2.png diff --git a/demos/mobile/quickhit/plugins/LevelOne/gfx/enemy_missile2.png b/demos/mobile/quickhit/plugins/LevelOne/gfx/enemy_missile2.png Binary files differnew file mode 100644 index 0000000..c0b28d8 --- /dev/null +++ b/demos/mobile/quickhit/plugins/LevelOne/gfx/enemy_missile2.png diff --git a/demos/mobile/quickhit/plugins/LevelOne/gfx/fire.png b/demos/mobile/quickhit/plugins/LevelOne/gfx/fire.png Binary files differnew file mode 100644 index 0000000..8401034 --- /dev/null +++ b/demos/mobile/quickhit/plugins/LevelOne/gfx/fire.png diff --git a/demos/mobile/quickhit/plugins/LevelOne/gfx/fire2.png b/demos/mobile/quickhit/plugins/LevelOne/gfx/fire2.png Binary files differnew file mode 100644 index 0000000..139aa61 --- /dev/null +++ b/demos/mobile/quickhit/plugins/LevelOne/gfx/fire2.png diff --git a/demos/mobile/quickhit/plugins/LevelOne/gfx/missile2.png b/demos/mobile/quickhit/plugins/LevelOne/gfx/missile2.png Binary files differnew file mode 100644 index 0000000..dacd610 --- /dev/null +++ b/demos/mobile/quickhit/plugins/LevelOne/gfx/missile2.png diff --git a/demos/mobile/quickhit/plugins/LevelOne/gfx/red_fire.png b/demos/mobile/quickhit/plugins/LevelOne/gfx/red_fire.png Binary files differnew file mode 100644 index 0000000..464d603 --- /dev/null +++ b/demos/mobile/quickhit/plugins/LevelOne/gfx/red_fire.png diff --git a/demos/mobile/quickhit/plugins/LevelOne/gfx/ship.png b/demos/mobile/quickhit/plugins/LevelOne/gfx/ship.png Binary files differnew file mode 100644 index 0000000..cb7851c --- /dev/null +++ b/demos/mobile/quickhit/plugins/LevelOne/gfx/ship.png diff --git a/demos/mobile/quickhit/plugins/LevelOne/gfx/star3.png b/demos/mobile/quickhit/plugins/LevelOne/gfx/star3.png Binary files differnew file mode 100644 index 0000000..f37a391 --- /dev/null +++ b/demos/mobile/quickhit/plugins/LevelOne/gfx/star3.png diff --git a/demos/mobile/quickhit/plugins/LevelOne/gfx/transparent.png b/demos/mobile/quickhit/plugins/LevelOne/gfx/transparent.png Binary files differnew file mode 100644 index 0000000..3aa1e41 --- /dev/null +++ b/demos/mobile/quickhit/plugins/LevelOne/gfx/transparent.png diff --git a/demos/mobile/quickhit/plugins/LevelOne/levelone.cpp b/demos/mobile/quickhit/plugins/LevelOne/levelone.cpp new file mode 100644 index 0000000..a3aa1f6 --- /dev/null +++ b/demos/mobile/quickhit/plugins/LevelOne/levelone.cpp @@ -0,0 +1,120 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "levelone.h" +#include <QtCore/qplugin.h> + + +LevelOne::LevelOne() +{ +} + +LevelOne::~LevelOne() +{ +} + +QString LevelOne::pathPrefix() +{ + /* +QDir::rootPath() +For Unix operating systems this returns "/". +For Windows file systems this normally returns "c:/". +On Symbian this typically returns "c:/data", +*/ + +#ifdef Q_WS_MAEMO_5 + return "/home/user/."; +#elif defined Q_OS_WIN32 + return QDir::rootPath(); +#else + //return QDir::rootPath()+"/"; + return "c:/System/"; +#endif +} + +QStringList LevelOne::levelSounds() +{ + QStringList list; + + // NOTE: Mandatory sounds/indexs for the all levels + // 0 = Enemy explode + list.append(LevelOne::pathPrefix()+"quickhitdata/levelone/sound/rocket_explosion.wav"); + // 1 = You explode + list.append(LevelOne::pathPrefix()+"quickhitdata/levelone/sound/crash.wav"); + // 2 = Missile fires + list.append(LevelOne::pathPrefix()+"quickhitdata/levelone/sound/rocket_explosion.wav"); + // 3 = Emeny Missile fires + list.append(LevelOne::pathPrefix()+"quickhitdata/levelone/sound/rocket.wav"); + + // Additional sounds + // Level starts + list.append(LevelOne::pathPrefix()+"quickhitdata/levelone/sound/levelonestart.wav"); + + return list; +} + +QVariant LevelOne::getData(QVariant key) +{ + QVariant ret; + switch (key.toInt()) { + case 1: { + // Any data what you need for this key + // Set your data into QVariant (ret) + break; + } + default: { + break; + } + } + return ret; +} + +QVariant LevelOne::graphSize(QVariant pathToGraph) +{ + QVariant ret; + m_imageReader.setFileName(pathToGraph.toString()); + QSize imageSize = m_imageReader.size(); + ret.setValue(imageSize); + return ret; +} + +// This Qt macro exports the plugin class LevelOne with the name levelplugins. +// There should be exactly one occurrence of this LevelOne macro in a Qt plugin's source code. +Q_EXPORT_PLUGIN2(levelplugins, LevelOne); diff --git a/demos/mobile/quickhit/plugins/LevelOne/levelone.h b/demos/mobile/quickhit/plugins/LevelOne/levelone.h new file mode 100644 index 0000000..6c64d79 --- /dev/null +++ b/demos/mobile/quickhit/plugins/LevelOne/levelone.h @@ -0,0 +1,91 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef LEVELONE_H +#define LEVELONE_H + +#include <QObject> +#include <QDir> +#include <QImageReader> + +#include "levelplugininterface.h" + +class LevelOne : public LevelPluginInterface +{ + Q_OBJECT + + // This macro tells Qt which interfaces the class implements. + // This is used when implementing plugins. + Q_INTERFACES(LevelPluginInterface) + +public: + LevelOne(); + ~LevelOne(); + + static QString pathPrefix(); + +public: // From LevelPluginInterface + + QStringList levelSounds(); + + Q_INVOKABLE QVariant getData(QVariant key); + + Q_INVOKABLE QVariant graphSize(QVariant pathToGraph); + + Q_INVOKABLE QVariant enemyCount() { return QVariant(30); } // 6x5=30 + Q_INVOKABLE QVariant enemyRowCount() { return QVariant(6); } // 6 rows of enemies + Q_INVOKABLE QVariant enemySpeed() { return QVariant(36000); } + Q_INVOKABLE QVariant enemyFireSpeed() { return QVariant(200); } + + // Root paths for the QML, Pictures and Sounds + Q_INVOKABLE QVariant qmlRootPath() { return QVariant(LevelOne::pathPrefix()+"quickhitdata/levelone/"); } + Q_INVOKABLE QVariant pictureRootPath() { return QVariant(LevelOne::pathPrefix()+"quickhitdata/levelone/gfx/"); } + + // Full paths + Q_INVOKABLE QVariant pathToTransparentEnemyPic() {return QVariant(LevelOne::pathPrefix()+"quickhitdata/levelone/gfx/transparent.png");} + Q_INVOKABLE QVariant pathToMissilePic() {return QVariant(LevelOne::pathPrefix()+"quickhitdata/levelone/gfx/missile2.png");} + Q_INVOKABLE QVariant pathToEnemyMissilePic() {return QVariant(LevelOne::pathPrefix()+"quickhitdata/levelone/gfx/enemy_missile2.png");} + Q_INVOKABLE QVariant pathToMyShipPic() {return QVariant(LevelOne::pathPrefix()+"quickhitdata/levelone/gfx/ship.png");} + +protected: + QImageReader m_imageReader; +}; + +#endif // LEVELONE_H diff --git a/demos/mobile/quickhit/plugins/LevelOne/levelone.pro b/demos/mobile/quickhit/plugins/LevelOne/levelone.pro new file mode 100644 index 0000000..fcbfc56 --- /dev/null +++ b/demos/mobile/quickhit/plugins/LevelOne/levelone.pro @@ -0,0 +1,100 @@ + +# Copyright (c) 2010 Nokia Corporation. + +TEMPLATE = lib + +#VERSION = 1.1.0 + +CONFIG += plugin + +INCLUDEPATH += ../ + +HEADERS = levelone.h + +SOURCES = levelone.cpp + +TARGET = $$qtLibraryTarget(levelone) + +OTHER_FILES += Level.qml + + +# SYMBIAN --------------------------- +symbian: { +# Load predefined include paths (e.g. QT_PLUGINS_BASE_DIR) to be used in the pro-files +load(data_caging_paths) + +# EPOCALLOWDLLDATA have to set true because Qt macros has initialised global data +TARGET.EPOCALLOWDLLDATA=1 +TARGET.UID3 = 0xE07dfb66 + +TARGET.CAPABILITY = NetworkServices \ + Location \ + ReadUserData \ + WriteUserData \ + LocalServices \ + UserEnvironment + +# Defines plugin stub file into Symbian .pkg package +pluginDep.sources = levelone.dll +pluginDep.path = $$QT_PLUGINS_BASE_DIR/quickhitlevels +DEPLOYMENT += pluginDep + +# Graphics and Sounds for the plugin +BLD_INF_RULES.prj_exports += "gfx/background3.png ../winscw/c/Data/gfx/background3.png" \ +"gfx/enemy1.png ../winscw/c/Data/gfx/enemy1.png" \ +"gfx/enemy2.png ../winscw/c/Data/gfx/enemy2.png" \ +"gfx/red_fire.png ../winscw/c/Data/gfx/red_fire.png" \ +"gfx/missile2.png ../winscw/c/Data/gfx/missile2.png" \ +"gfx/enemy_missile2.png ../winscw/c/Data/gfx/enemy_missile2.png" \ +"gfx/ship.png ../winscw/c/Data/gfx/ship.png" \ +"gfx/transparent.png ../winscw/c/Data/gfx/transparent.png" \ +"gfx/star3.png ../winscw/c/Data/gfx/star3.png" \ +"sound/crash.wav ../winscw/c/Data/sound/crash.wav" \ +"sound/rocket.wav ../winscw/c/Data/sound/rocket.wav" \ +"sound/rocket_explosion.wav ../winscw/c/Data/sound/rocket_explosion.wav" \ +"sound/levelonestart.wav ../winscw/c/Data/sound/levelonestart.wav" \ +"Level.qml ../winscw/c/Data/Level.qml" + + +myQml.sources = level.qml +myQml.path = c:/System/quickhitdata/levelone +myGraphic.sources = gfx/* +myGraphic.path = c:/System/quickhitdata/levelone/gfx +mySound.sources = sound/* +mySound.path = c:/System/quickhitdata/levelone/sound +# Takes qml, graphics and sounds into Symbian SIS package file (.pkg) +DEPLOYMENT += myQml myGraphic mySound + +target.path += $$[QT_INSTALL_PLUGINS]/quickhitlevels +# Installs binaries +INSTALLS += target +} + +# WINDOWS --------------------------- +win32: { +# Copy level sounds and graphics into right destination +system(mkdir c:\\quickhitdata\\levelone) +system(mkdir c:\\quickhitdata\\levelone\\gfx) +system(mkdir c:\\quickhitdata\\levelone\\sound) +system(copy *.qml c:\\quickhitdata\\levelone) +system(copy gfx\\*.* c:\\quickhitdata\\levelone\\gfx) +system(copy sound\\*.* c:\\quickhitdata\\levelone\\sound) + +# Installs binaries +target.path += $$[QT_INSTALL_PLUGINS]/quickhitlevels +INSTALLS += target +} + +# MAEMO_5 --------------------------- +maemo5: { +myQml.path = /home/user/.quickhitdata/levelone/ +myQml.files += Level.qml +myGraphic.path = /home/user/.quickhitdata/levelone/gfx/ +myGraphic.files += gfx/* +mySound.path = /home/user/.quickhitdata/levelone/sound/ +mySound.files += sound/* + +target.path += /usr/lib/qt4/plugins/quickhitlevels +# Installs qml, binaries, sounds and graphics +INSTALLS += target myGraphic mySound myQml +} diff --git a/demos/mobile/quickhit/plugins/LevelOne/sound/crash.wav b/demos/mobile/quickhit/plugins/LevelOne/sound/crash.wav Binary files differnew file mode 100644 index 0000000..8076f0f --- /dev/null +++ b/demos/mobile/quickhit/plugins/LevelOne/sound/crash.wav diff --git a/demos/mobile/quickhit/plugins/LevelOne/sound/levelonestart.wav b/demos/mobile/quickhit/plugins/LevelOne/sound/levelonestart.wav Binary files differnew file mode 100644 index 0000000..e9e3ac0 --- /dev/null +++ b/demos/mobile/quickhit/plugins/LevelOne/sound/levelonestart.wav diff --git a/demos/mobile/quickhit/plugins/LevelOne/sound/rocket.wav b/demos/mobile/quickhit/plugins/LevelOne/sound/rocket.wav Binary files differnew file mode 100644 index 0000000..8c0dee9 --- /dev/null +++ b/demos/mobile/quickhit/plugins/LevelOne/sound/rocket.wav diff --git a/demos/mobile/quickhit/plugins/LevelOne/sound/rocket_explosion.wav b/demos/mobile/quickhit/plugins/LevelOne/sound/rocket_explosion.wav Binary files differnew file mode 100644 index 0000000..d2b451c --- /dev/null +++ b/demos/mobile/quickhit/plugins/LevelOne/sound/rocket_explosion.wav diff --git a/demos/mobile/quickhit/plugins/LevelTemplate/debian/changelog b/demos/mobile/quickhit/plugins/LevelTemplate/debian/changelog new file mode 100644 index 0000000..a5e0a1b --- /dev/null +++ b/demos/mobile/quickhit/plugins/LevelTemplate/debian/changelog @@ -0,0 +1,11 @@ +leveltemplate (1.1.0) unstable; urgency=low + + * Final graphics + + -- Antonio Aloisio <antonio.aloisio@nokia.com> Wed, 5 Jan 2011 10:05:04 +0200 + +leveltemplate (1.0.0) unstable; urgency=low + + * First version + + -- Antonio Aloisio <antonio.aloisio@nokia.com> Tue, 19 Oct 2010 10:05:04 +0200 diff --git a/demos/mobile/quickhit/plugins/LevelTemplate/debian/compat b/demos/mobile/quickhit/plugins/LevelTemplate/debian/compat new file mode 100644 index 0000000..7f8f011 --- /dev/null +++ b/demos/mobile/quickhit/plugins/LevelTemplate/debian/compat @@ -0,0 +1 @@ +7 diff --git a/demos/mobile/quickhit/plugins/LevelTemplate/debian/control b/demos/mobile/quickhit/plugins/LevelTemplate/debian/control new file mode 100644 index 0000000..68742fd --- /dev/null +++ b/demos/mobile/quickhit/plugins/LevelTemplate/debian/control @@ -0,0 +1,11 @@ +Source: leveltemplate +Section: user/games +Priority: extra +Maintainer: Antonio Aloisio <antonio.aloisio@nokia.com> +Standards-Version: 3.7.2 + +Package: leveltemplate +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends} +Description: QuickHit - Level Template + QuickHit - Level Template diff --git a/demos/mobile/quickhit/plugins/LevelTemplate/debian/copyright b/demos/mobile/quickhit/plugins/LevelTemplate/debian/copyright new file mode 100644 index 0000000..f9ee8e2 --- /dev/null +++ b/demos/mobile/quickhit/plugins/LevelTemplate/debian/copyright @@ -0,0 +1,8 @@ +This is leveltemplate, written and maintained by Forum Nokia Antonio Aloisio <antonio.aloisio@nokia.com> +on Tue, 19 Oct 2010 10:05:04 +0200 + + +Copyright Holder: Nokia (c) 2010 + +License: + diff --git a/demos/mobile/quickhit/plugins/LevelTemplate/debian/dirs b/demos/mobile/quickhit/plugins/LevelTemplate/debian/dirs new file mode 100644 index 0000000..80507f1 --- /dev/null +++ b/demos/mobile/quickhit/plugins/LevelTemplate/debian/dirs @@ -0,0 +1,2 @@ +usr/bin +usr/share/applications/hildon diff --git a/demos/mobile/quickhit/plugins/LevelTemplate/debian/levelone.tarlist b/demos/mobile/quickhit/plugins/LevelTemplate/debian/levelone.tarlist new file mode 100644 index 0000000..f3146fa1 --- /dev/null +++ b/demos/mobile/quickhit/plugins/LevelTemplate/debian/levelone.tarlist @@ -0,0 +1,41 @@ +755 root root . home / +755 root root . home/maemo / +755 root root . home/maemo/quickhitdata / +755 root root . home/maemo/quickhitdata/levelone / +644 root root . home/maemo/quickhitdata/levelone/Level.qml debian/levelone/home/maemo/quickhitdata/levelone/Level.qml +755 root root . home/maemo/quickhitdata/leveltwo / +755 root root . home/maemo/quickhitdata/leveltwo/gfx / +644 root root . home/maemo/quickhitdata/leveltwo/gfx/background3.png debian/levelone/home/maemo/quickhitdata/leveltwo/gfx/background3.png +644 root root . home/maemo/quickhitdata/leveltwo/gfx/blue_fire.png debian/levelone/home/maemo/quickhitdata/leveltwo/gfx/blue_fire.png +644 root root . home/maemo/quickhitdata/leveltwo/gfx/enemy1.png debian/levelone/home/maemo/quickhitdata/leveltwo/gfx/enemy1.png +644 root root . home/maemo/quickhitdata/leveltwo/gfx/enemy2.png debian/levelone/home/maemo/quickhitdata/leveltwo/gfx/enemy2.png +644 root root . home/maemo/quickhitdata/leveltwo/gfx/enemy_missile2.png debian/levelone/home/maemo/quickhitdata/leveltwo/gfx/enemy_missile2.png +644 root root . home/maemo/quickhitdata/leveltwo/gfx/fire.png debian/levelone/home/maemo/quickhitdata/leveltwo/gfx/fire.png +644 root root . home/maemo/quickhitdata/leveltwo/gfx/fire2.png debian/levelone/home/maemo/quickhitdata/leveltwo/gfx/fire2.png +644 root root . home/maemo/quickhitdata/leveltwo/gfx/missile.png debian/levelone/home/maemo/quickhitdata/leveltwo/gfx/missile.png +644 root root . home/maemo/quickhitdata/leveltwo/gfx/missile2.png debian/levelone/home/maemo/quickhitdata/leveltwo/gfx/missile2.png +644 root root . home/maemo/quickhitdata/leveltwo/gfx/moon.png debian/levelone/home/maemo/quickhitdata/leveltwo/gfx/moon.png +644 root root . home/maemo/quickhitdata/leveltwo/gfx/ship.png debian/levelone/home/maemo/quickhitdata/leveltwo/gfx/ship.png +644 root root . home/maemo/quickhitdata/leveltwo/gfx/star3.png debian/levelone/home/maemo/quickhitdata/leveltwo/gfx/star3.png +644 root root . home/maemo/quickhitdata/leveltwo/gfx/transparent.png debian/levelone/home/maemo/quickhitdata/leveltwo/gfx/transparent.png +755 root root . home/maemo/quickhitdata/leveltwo/sound / +644 root root . home/maemo/quickhitdata/leveltwo/sound/crash.wav debian/levelone/home/maemo/quickhitdata/leveltwo/sound/crash.wav +644 root root . home/maemo/quickhitdata/leveltwo/sound/enemy_explosion.wav debian/levelone/home/maemo/quickhitdata/leveltwo/sound/enemy_explosion.wav +644 root root . home/maemo/quickhitdata/leveltwo/sound/laser.wav debian/levelone/home/maemo/quickhitdata/leveltwo/sound/laser.wav +644 root root . home/maemo/quickhitdata/leveltwo/sound/myship_explosion.wav debian/levelone/home/maemo/quickhitdata/leveltwo/sound/myship_explosion.wav +644 root root . home/maemo/quickhitdata/leveltwo/sound/rocket.wav debian/levelone/home/maemo/quickhitdata/leveltwo/sound/rocket.wav +644 root root . home/maemo/quickhitdata/leveltwo/sound/rocket_explosion.wav debian/levelone/home/maemo/quickhitdata/leveltwo/sound/rocket_explosion.wav +755 root root . usr / +755 root root . usr/bin / +755 root root . usr/lib / +755 root root . usr/lib/qt4 / +755 root root . usr/lib/qt4/plugins / +755 root root . usr/lib/qt4/plugins/quickhitlevels / +644 root root . usr/lib/qt4/plugins/quickhitlevels/libleveltwo.so debian/levelone/usr/lib/qt4/plugins/quickhitlevels/libleveltwo.so +755 root root . usr/share / +755 root root . usr/share/applications / +755 root root . usr/share/applications/hildon / +755 root root . usr/share/doc / +755 root root . usr/share/doc/levelone / +644 root root . usr/share/doc/levelone/changelog.gz debian/levelone/usr/share/doc/levelone/changelog.gz +644 root root . usr/share/doc/levelone/copyright debian/levelone/usr/share/doc/levelone/copyright diff --git a/demos/mobile/quickhit/plugins/LevelTemplate/debian/postinst b/demos/mobile/quickhit/plugins/LevelTemplate/debian/postinst new file mode 100644 index 0000000..79fb6dd --- /dev/null +++ b/demos/mobile/quickhit/plugins/LevelTemplate/debian/postinst @@ -0,0 +1,5 @@ +#!/bin/sh -e + +gtk-update-icon-cache -f /usr/share/icons/hicolor + +exit 0 diff --git a/demos/mobile/quickhit/plugins/LevelTemplate/debian/rules b/demos/mobile/quickhit/plugins/LevelTemplate/debian/rules new file mode 100644 index 0000000..7f30ca3 --- /dev/null +++ b/demos/mobile/quickhit/plugins/LevelTemplate/debian/rules @@ -0,0 +1,91 @@ +#!/usr/bin/make -f +# -*- makefile -*- +# Sample debian/rules that uses debhelper. +# This file was originally written by Joey Hess and Craig Small. +# As a special exception, when this file is copied by dh-make into a +# dh-make output file, you may use that output file without restriction. +# This special exception was added by Craig Small in version 0.37 of dh-make. + +# Uncomment this to turn on verbose mode. +#export DH_VERBOSE=1 + + +APPNAME := leveltemplate + + +configure: configure-stamp +configure-stamp: + dh_testdir + # Add here commands to configure the package. + + touch configure-stamp + + +build: build-stamp + +build-stamp: configure-stamp + dh_testdir + + # Add here commands to compile the package. + $(MAKE) + #docbook-to-man debian/$(APPNAME).sgml > $(APPNAME).1 + + touch $@ + +clean: + dh_testdir + dh_testroot + rm -f build-stamp configure-stamp + + # Add here commands to clean up after the build process. + $(MAKE) clean + + dh_clean + +install: build + dh_testdir + dh_testroot + dh_clean -k + dh_installdirs + + # Add here commands to install the package into debian/$(APPNAME). + $(MAKE) INSTALL_ROOT="$(CURDIR)"/debian/$(APPNAME) install + + +# Build architecture-independent files here. +binary-indep: build install +# We have nothing to do by default. + +# Build architecture-dependent files here. +binary-arch: build install + dh_testdir + dh_testroot + dh_installchangelogs + dh_installdocs + dh_installexamples +# dh_install +# dh_installmenu +# dh_installdebconf +# dh_installlogrotate +# dh_installemacsen +# dh_installpam +# dh_installmime +# dh_python +# dh_installinit +# dh_installcron +# dh_installinfo + dh_installman + dh_link + # dh_strip + dh_compress + dh_fixperms +# dh_perl + dh_makeshlibs + dh_installdeb + dh_shlibdeps + dh_gencontrol + dh_md5sums + dh_builddeb + +binary: binary-indep binary-arch +.PHONY: build clean binary-indep binary-arch binary install configure diff --git a/demos/mobile/quickhit/plugins/LevelTemplate/gfx/blue_fire.png b/demos/mobile/quickhit/plugins/LevelTemplate/gfx/blue_fire.png Binary files differnew file mode 100644 index 0000000..8667a39 --- /dev/null +++ b/demos/mobile/quickhit/plugins/LevelTemplate/gfx/blue_fire.png diff --git a/demos/mobile/quickhit/plugins/LevelTemplate/gfx/enemy1.png b/demos/mobile/quickhit/plugins/LevelTemplate/gfx/enemy1.png Binary files differnew file mode 100644 index 0000000..94f149b --- /dev/null +++ b/demos/mobile/quickhit/plugins/LevelTemplate/gfx/enemy1.png diff --git a/demos/mobile/quickhit/plugins/LevelTemplate/gfx/enemy2.png b/demos/mobile/quickhit/plugins/LevelTemplate/gfx/enemy2.png Binary files differnew file mode 100644 index 0000000..448f8ca --- /dev/null +++ b/demos/mobile/quickhit/plugins/LevelTemplate/gfx/enemy2.png diff --git a/demos/mobile/quickhit/plugins/LevelTemplate/gfx/enemy_missile2.png b/demos/mobile/quickhit/plugins/LevelTemplate/gfx/enemy_missile2.png Binary files differnew file mode 100644 index 0000000..c0b28d8 --- /dev/null +++ b/demos/mobile/quickhit/plugins/LevelTemplate/gfx/enemy_missile2.png diff --git a/demos/mobile/quickhit/plugins/LevelTemplate/gfx/missile2.png b/demos/mobile/quickhit/plugins/LevelTemplate/gfx/missile2.png Binary files differnew file mode 100644 index 0000000..dacd610 --- /dev/null +++ b/demos/mobile/quickhit/plugins/LevelTemplate/gfx/missile2.png diff --git a/demos/mobile/quickhit/plugins/LevelTemplate/gfx/ship.png b/demos/mobile/quickhit/plugins/LevelTemplate/gfx/ship.png Binary files differnew file mode 100644 index 0000000..cb7851c --- /dev/null +++ b/demos/mobile/quickhit/plugins/LevelTemplate/gfx/ship.png diff --git a/demos/mobile/quickhit/plugins/LevelTemplate/gfx/transparent.png b/demos/mobile/quickhit/plugins/LevelTemplate/gfx/transparent.png Binary files differnew file mode 100644 index 0000000..3aa1e41 --- /dev/null +++ b/demos/mobile/quickhit/plugins/LevelTemplate/gfx/transparent.png diff --git a/demos/mobile/quickhit/plugins/LevelTemplate/leveltemplate.cpp b/demos/mobile/quickhit/plugins/LevelTemplate/leveltemplate.cpp new file mode 100644 index 0000000..fffec69 --- /dev/null +++ b/demos/mobile/quickhit/plugins/LevelTemplate/leveltemplate.cpp @@ -0,0 +1,126 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "leveltemplate.h" +#include <QtCore/qplugin.h> + + +LevelTemplate::LevelTemplate() +{ +} + +LevelTemplate::~LevelTemplate() +{ +} + +QString LevelTemplate::pathPrefix() +{ +/* +QDir::rootPath() +For Unix operating systems this returns "/". +For Windows file systems this normally returns "c:/". +On Symbian this typically returns "c:/data", +*/ + +#ifdef Q_WS_MAEMO_5 + return "/home/user/."; +#elif defined Q_OS_WIN32 + return QDir::rootPath(); +#else + //return QDir::rootPath()+"/"; + return "c:/System/"; +#endif +} + +QStringList LevelTemplate::levelSounds() +{ + QStringList list; + + + // NOTE: Mandatory sounds/indexs for the all levels + // 0 = Enemy explode + list.append(LevelTemplate::pathPrefix()+"quickhitdata/"+LEVEL_NAME+"/sound/enemy_explosion.wav"); + // 1 = You explode + list.append(LevelTemplate::pathPrefix()+"quickhitdata/"+LEVEL_NAME+"/sound/myship_explosion.wav"); + // 2 = Missile fires + list.append(LevelTemplate::pathPrefix()+"quickhitdata/"+LEVEL_NAME+"/sound/laser.wav"); + // 3 = Emeny Missile fires + list.append(LevelTemplate::pathPrefix()+"quickhitdata/"+LEVEL_NAME+"/sound/rocket.wav"); + + // Additional sounds + list.append(LevelTemplate::pathPrefix()+"quickhitdata/"+LEVEL_NAME+"/sound/enableship.wav"); + list.append(LevelTemplate::pathPrefix()+"quickhitdata/"+LEVEL_NAME+"/sound/level2.wav"); + + + return list; +} + +QVariant LevelTemplate::getData(QVariant key) +{ + QVariant ret; + switch (key.toInt()) { + case 1: { + // Any data what you need for this key + // Set your data into QVariant (ret) + break; + } + default: { + break; + } + } + return ret; +} + +QVariant LevelTemplate::graphSize(QVariant pathToGraph) +{ + QVariant ret; + m_imageReader.setFileName(pathToGraph.toString()); + QSize imageSize = m_imageReader.size(); + ret.setValue(imageSize); + return ret; +} + +// This Qt macro exports the plugin class level with the name levelplugins. +// There should be exactly one occurrence of this macro in a Qt plugin's source code. +Q_EXPORT_PLUGIN2(levelplugins, LevelTemplate); + + + + diff --git a/demos/mobile/quickhit/plugins/LevelTemplate/leveltemplate.h b/demos/mobile/quickhit/plugins/LevelTemplate/leveltemplate.h new file mode 100644 index 0000000..f13705a --- /dev/null +++ b/demos/mobile/quickhit/plugins/LevelTemplate/leveltemplate.h @@ -0,0 +1,95 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef LevelTemplate_H +#define LevelTemplate_H + +#include <QObject> +#include <QDir> +#include <QImageReader> + +// Common interface header for all level plugins +#include "levelplugininterface.h" + +// Level name +#define LEVEL_NAME "leveltemplate" + +class LevelTemplate : public LevelPluginInterface +{ + Q_OBJECT + + // This macro tells Qt which interfaces the class implements. + // This is used when implementing plugins. + Q_INTERFACES(LevelPluginInterface) + +public: + LevelTemplate(); + ~LevelTemplate(); + + static QString pathPrefix(); + +public: // From LevelPluginInterface + + QStringList levelSounds(); + + Q_INVOKABLE QVariant getData(QVariant key); + + Q_INVOKABLE QVariant graphSize(QVariant pathToGraph); + + Q_INVOKABLE QVariant enemyCount() { return QVariant(1); } + Q_INVOKABLE QVariant enemyRowCount() { return QVariant(0); } + Q_INVOKABLE QVariant enemySpeed() { return QVariant(20000); } + Q_INVOKABLE QVariant enemyFireSpeed() { return QVariant(2000); } + + // Root paths for the QML, Pictures and Sounds + Q_INVOKABLE QVariant qmlRootPath() { return QVariant(LevelTemplate::pathPrefix()+"quickhitdata/"+LEVEL_NAME+"/"); } + Q_INVOKABLE QVariant pictureRootPath() { return QVariant(LevelTemplate::pathPrefix()+"quickhitdata/"+LEVEL_NAME+"/gfx/"); } + + // Full paths + Q_INVOKABLE QVariant pathToTransparentEnemyPic() {return QVariant(LevelTemplate::pathPrefix()+"quickhitdata/"+LEVEL_NAME+"/gfx/transparent.png");} + Q_INVOKABLE QVariant pathToMissilePic() {return QVariant(LevelTemplate::pathPrefix()+"quickhitdata/"+LEVEL_NAME+"/gfx/missile2.png");} + Q_INVOKABLE QVariant pathToEnemyMissilePic() {return QVariant(LevelTemplate::pathPrefix()+"quickhitdata/"+LEVEL_NAME+"/gfx/enemy_missile2.png");} + Q_INVOKABLE QVariant pathToMyShipPic() {return QVariant(LevelTemplate::pathPrefix()+"quickhitdata/"+LEVEL_NAME+"/gfx/ship.png");} + +protected: + QImageReader m_imageReader; +}; + +#endif // LevelTemplate_H diff --git a/demos/mobile/quickhit/plugins/LevelTemplate/leveltemplate.pro b/demos/mobile/quickhit/plugins/LevelTemplate/leveltemplate.pro new file mode 100644 index 0000000..a4f5900 --- /dev/null +++ b/demos/mobile/quickhit/plugins/LevelTemplate/leveltemplate.pro @@ -0,0 +1,103 @@ + +# Copyright (c) 2010 Nokia Corporation. + +TEMPLATE = lib + +#VERSION = 1.1.0 + +CONFIG += plugin + +INCLUDEPATH += ../ + +HEADERS = leveltemplate.h + +SOURCES = leveltemplate.cpp + +TARGET = $$qtLibraryTarget(leveltemplate) + +OTHER_FILES += qml/Level.qml \ + qml/Enemy.qml \ + qml/Level.js + + +# SYMBIAN --------------------------- +symbian: { +# Load predefined include paths (e.g. QT_PLUGINS_BASE_DIR) to be used in the pro-files +load(data_caging_paths) + +# EPOCALLOWDLLDATA have to set true because Qt macros has initialised global data +TARGET.EPOCALLOWDLLDATA=1 +TARGET.UID3 = 0xE07dfb68 + +TARGET.CAPABILITY = NetworkServices \ + Location \ + ReadUserData \ + WriteUserData \ + LocalServices \ + UserEnvironment + +# Defines plugin stub file into Symbian .pkg package +pluginDep.sources = leveltemplate.dll +pluginDep.path = $$QT_PLUGINS_BASE_DIR/quickhitlevels +DEPLOYMENT += pluginDep + +# Graphics and Sounds for the plugin +BLD_INF_RULES.prj_exports += "gfx/enemy1.png ../winscw/c/Data/gfx/enemy1.png" \ +"gfx/enemy2.png ../winscw/c/Data/gfx/enemy2.png" \ +"gfx/missile2.png ../winscw/c/Data/gfx/missile2.png" \ +"gfx/enemy_missile2.png ../winscw/c/Data/gfx/enemy_missile2.png" \ +"gfx/ship.png ../winscw/c/Data/gfx/ship.png" \ +"gfx/transparent.png ../winscw/c/Data/gfx/transparent.png" \ +"gfx/blue_fire.png ../winscw/c/Data/gfx/blue_fire.png" \ +"sound/enemy_explosion.wav ../winscw/c/Data/sound/enemy_explosion.wav" \ +"sound/myship_explosion.wav ../winscw/c/Data/sound/myship_explosion.wav" \ +"sound/enableship.wav ../winscw/c/Data/sound/enableship.wav" \ +"sound/laser.wav ../winscw/c/Data/sound/laser.wav" \ +"sound/level2.wav ../winscw/c/Data/sound/level2.wav" \ +"qml/Level.qml ../winscw/c/Data/Level.qml" \ +"qml/Level.js ../winscw/c/Data/Level.js" \ +"qml/Enemy.qml ../winscw/c/Data/Enemy.qml" + + +myQml.sources = qml/* +myQml.path = c:/System/quickhitdata/leveltemplate +myGraphic.sources = gfx/* +myGraphic.path = c:/System/quickhitdata/leveltemplate/gfx +mySound.sources = sound/* +mySound.path = c:/System/quickhitdata/leveltemplate/sound +# Takes qml, graphics and sounds into Symbian SIS package file (.pkg) +DEPLOYMENT += myQml myGraphic mySound + +target.path += $$[QT_INSTALL_PLUGINS]/quickhitlevels +# Installs binaries +INSTALLS += target +} + +# WINDOWS --------------------------- +win32: { +# Copy level sounds and graphics into right destination +system(mkdir c:\quickhitdata\leveltemplate) +system(mkdir c:\quickhitdata\leveltemplate\gfx) +system(mkdir c:\quickhitdata\leveltemplate\sound) +system(copy qml\*.* c:\quickhitdata\leveltemplate) +system(copy gfx\*.* c:\quickhitdata\leveltemplate\gfx) +system(copy sound\*.* c:\quickhitdata\leveltemplate\sound) + +# Installs binaries +target.path += $$[QT_INSTALL_PLUGINS]/quickhitlevels +INSTALLS += target +} + +# MAEMO_5 --------------------------- +maemo5: { +myQml.path = /home/user/.quickhitdata/leveltemplate/ +myQml.files += qml/* +myGraphic.path = /home/user/.quickhitdata/leveltemplate/gfx/ +myGraphic.files += gfx/* +mySound.path = /home/user/.quickhitdata/leveltemplate/sound/ +mySound.files += sound/* + +target.path += /usr/lib/qt4/plugins/quickhitlevels +# Installs qml, binaries, sounds and graphics +INSTALLS += target myGraphic mySound myQml +} diff --git a/demos/mobile/quickhit/plugins/LevelTemplate/qml/Enemy.qml b/demos/mobile/quickhit/plugins/LevelTemplate/qml/Enemy.qml new file mode 100644 index 0000000..b187c03 --- /dev/null +++ b/demos/mobile/quickhit/plugins/LevelTemplate/qml/Enemy.qml @@ -0,0 +1,61 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 1.0 + +Image { + id: enemy + + // *************************************************** + // *** NOTE: This "enemy "is mandatory enemy object name for all enemy QML files + objectName: "enemy" + + smooth:true + opacity: 0 // 0=hidden by default + fillMode:Image.PreserveAspectFit + source:"file:/"+LevelPlugin.pictureRootPath()+"enemy1.png" + + property int enemySpeed: LevelPlugin.enemySpeed() + + // *************************************************** + // *** NOTE: This "pause(bool)" function is mandatory for all enemies QML files + function pause(doPause) { + } +} diff --git a/demos/mobile/quickhit/plugins/LevelTemplate/qml/Level.js b/demos/mobile/quickhit/plugins/LevelTemplate/qml/Level.js new file mode 100644 index 0000000..e2e1d3a --- /dev/null +++ b/demos/mobile/quickhit/plugins/LevelTemplate/qml/Level.js @@ -0,0 +1,42 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ + +var hiddenEnemies = new Array() + diff --git a/demos/mobile/quickhit/plugins/LevelTemplate/qml/Level.qml b/demos/mobile/quickhit/plugins/LevelTemplate/qml/Level.qml new file mode 100644 index 0000000..3a383cf --- /dev/null +++ b/demos/mobile/quickhit/plugins/LevelTemplate/qml/Level.qml @@ -0,0 +1,103 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 1.0 +import Qt.labs.particles 1.0 + +// Level own JavaScript file +import "Level.js" as LevelScript + +Rectangle { + id: enemies + anchors.fill: parent + property int enemiesCreated: 0 + property int enemiesEnabled: 0 + color: "black" + + // *************************************************** + // *** NOTE: This "pause(bool)" function is mandatory for all level QML files + function pause(doPause) { + } + + // *************************************************** + // *** NOTE: Level object name "level" is mandatory for all level QML files + objectName: "level" + + // Enemy placeholder. Have to exist at least one enemy for prevent to level be stopped + Enemy { + x: parent.width / 2 + y: parent.height / 2 + opacity: 1 + } + + // *************************************************** + // *** NOTE: This is mandatory for all level QML files + // Execute explode particle effect + function explode(x,y) { + explodeParticles.x = x + explodeParticles.y = y + explodeParticles.burst(20) + explodeParticles.opacity = 1 + } + + // *************************************************** + // *** NOTE: This is mandatory for all level QML files + // Explode particle effect + Particles { + id: explodeParticles + opacity: 0 + width: 1 + height: 1 + emissionRate: 0 + source: "file:/"+LevelPlugin.pictureRootPath()+"blue_fire.png" + lifeSpan: 500 + lifeSpanDeviation: 2000 + count: -1 + angle: 270 + angleDeviation: 65 + velocity: 100 + velocityDeviation: 100 + ParticleMotionGravity { + yattractor: 1000 + xattractor: 300 + acceleration: 50 + } + } +} diff --git a/demos/mobile/quickhit/plugins/LevelTemplate/sound/crash.wav b/demos/mobile/quickhit/plugins/LevelTemplate/sound/crash.wav Binary files differnew file mode 100644 index 0000000..8076f0f --- /dev/null +++ b/demos/mobile/quickhit/plugins/LevelTemplate/sound/crash.wav diff --git a/demos/mobile/quickhit/plugins/LevelTemplate/sound/enableship.wav b/demos/mobile/quickhit/plugins/LevelTemplate/sound/enableship.wav Binary files differnew file mode 100644 index 0000000..6fe5fe8 --- /dev/null +++ b/demos/mobile/quickhit/plugins/LevelTemplate/sound/enableship.wav diff --git a/demos/mobile/quickhit/plugins/LevelTemplate/sound/enemy_explosion.wav b/demos/mobile/quickhit/plugins/LevelTemplate/sound/enemy_explosion.wav Binary files differnew file mode 100644 index 0000000..fd338e6 --- /dev/null +++ b/demos/mobile/quickhit/plugins/LevelTemplate/sound/enemy_explosion.wav diff --git a/demos/mobile/quickhit/plugins/LevelTemplate/sound/laser.wav b/demos/mobile/quickhit/plugins/LevelTemplate/sound/laser.wav Binary files differnew file mode 100644 index 0000000..c3b58b2 --- /dev/null +++ b/demos/mobile/quickhit/plugins/LevelTemplate/sound/laser.wav diff --git a/demos/mobile/quickhit/plugins/LevelTemplate/sound/level2.wav b/demos/mobile/quickhit/plugins/LevelTemplate/sound/level2.wav Binary files differnew file mode 100644 index 0000000..24d3917 --- /dev/null +++ b/demos/mobile/quickhit/plugins/LevelTemplate/sound/level2.wav diff --git a/demos/mobile/quickhit/plugins/LevelTemplate/sound/myship_explosion.wav b/demos/mobile/quickhit/plugins/LevelTemplate/sound/myship_explosion.wav Binary files differnew file mode 100644 index 0000000..e22d030 --- /dev/null +++ b/demos/mobile/quickhit/plugins/LevelTemplate/sound/myship_explosion.wav diff --git a/demos/mobile/quickhit/plugins/LevelTemplate/sound/rocket.wav b/demos/mobile/quickhit/plugins/LevelTemplate/sound/rocket.wav Binary files differnew file mode 100644 index 0000000..8c0dee9 --- /dev/null +++ b/demos/mobile/quickhit/plugins/LevelTemplate/sound/rocket.wav diff --git a/demos/mobile/quickhit/plugins/LevelTemplate/sound/rocket_explosion.wav b/demos/mobile/quickhit/plugins/LevelTemplate/sound/rocket_explosion.wav Binary files differnew file mode 100644 index 0000000..d2b451c --- /dev/null +++ b/demos/mobile/quickhit/plugins/LevelTemplate/sound/rocket_explosion.wav diff --git a/demos/mobile/quickhit/plugins/LevelTwo/debian/changelog b/demos/mobile/quickhit/plugins/LevelTwo/debian/changelog new file mode 100644 index 0000000..106ef66 --- /dev/null +++ b/demos/mobile/quickhit/plugins/LevelTwo/debian/changelog @@ -0,0 +1,11 @@ +leveltwo (1.1.0) unstable; urgency=low + + * Final graphics + + -- Antonio Aloisio <antonio.aloisio@nokia.com> Wed, 5 Jan 2011 10:05:04 +0200 + +leveltwo (1.0.0) unstable; urgency=low + + * First version + + -- Antonio Aloisio <antonio.aloisio@nokia.com> Tue, 19 Oct 2010 10:05:04 +0200 diff --git a/demos/mobile/quickhit/plugins/LevelTwo/debian/compat b/demos/mobile/quickhit/plugins/LevelTwo/debian/compat new file mode 100644 index 0000000..7f8f011 --- /dev/null +++ b/demos/mobile/quickhit/plugins/LevelTwo/debian/compat @@ -0,0 +1 @@ +7 diff --git a/demos/mobile/quickhit/plugins/LevelTwo/debian/control b/demos/mobile/quickhit/plugins/LevelTwo/debian/control new file mode 100644 index 0000000..8f9d05e --- /dev/null +++ b/demos/mobile/quickhit/plugins/LevelTwo/debian/control @@ -0,0 +1,11 @@ +Source: leveltwo +Section: user/games +Priority: extra +Maintainer: Antonio Aloisio <antonio.aloisio@nokia.com> +Standards-Version: 3.7.2 + +Package: leveltwo +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends} +Description: QuickHit - LevelTwo + QuickHit - LevelTwo diff --git a/demos/mobile/quickhit/plugins/LevelTwo/debian/copyright b/demos/mobile/quickhit/plugins/LevelTwo/debian/copyright new file mode 100644 index 0000000..fb9e5a8 --- /dev/null +++ b/demos/mobile/quickhit/plugins/LevelTwo/debian/copyright @@ -0,0 +1,8 @@ +This is qmultiwinexample, written and maintained by Forum Nokia Antonio Aloisio <antonio.aloisio@nokia.com> +on Tue, 19 Oct 2010 10:05:04 +0200 + + +Copyright Holder: Nokia (c) 2010 + +License: + diff --git a/demos/mobile/quickhit/plugins/LevelTwo/debian/dirs b/demos/mobile/quickhit/plugins/LevelTwo/debian/dirs new file mode 100644 index 0000000..80507f1 --- /dev/null +++ b/demos/mobile/quickhit/plugins/LevelTwo/debian/dirs @@ -0,0 +1,2 @@ +usr/bin +usr/share/applications/hildon diff --git a/demos/mobile/quickhit/plugins/LevelTwo/debian/levelone.tarlist b/demos/mobile/quickhit/plugins/LevelTwo/debian/levelone.tarlist new file mode 100644 index 0000000..f3146fa1 --- /dev/null +++ b/demos/mobile/quickhit/plugins/LevelTwo/debian/levelone.tarlist @@ -0,0 +1,41 @@ +755 root root . home / +755 root root . home/maemo / +755 root root . home/maemo/quickhitdata / +755 root root . home/maemo/quickhitdata/levelone / +644 root root . home/maemo/quickhitdata/levelone/Level.qml debian/levelone/home/maemo/quickhitdata/levelone/Level.qml +755 root root . home/maemo/quickhitdata/leveltwo / +755 root root . home/maemo/quickhitdata/leveltwo/gfx / +644 root root . home/maemo/quickhitdata/leveltwo/gfx/background3.png debian/levelone/home/maemo/quickhitdata/leveltwo/gfx/background3.png +644 root root . home/maemo/quickhitdata/leveltwo/gfx/blue_fire.png debian/levelone/home/maemo/quickhitdata/leveltwo/gfx/blue_fire.png +644 root root . home/maemo/quickhitdata/leveltwo/gfx/enemy1.png debian/levelone/home/maemo/quickhitdata/leveltwo/gfx/enemy1.png +644 root root . home/maemo/quickhitdata/leveltwo/gfx/enemy2.png debian/levelone/home/maemo/quickhitdata/leveltwo/gfx/enemy2.png +644 root root . home/maemo/quickhitdata/leveltwo/gfx/enemy_missile2.png debian/levelone/home/maemo/quickhitdata/leveltwo/gfx/enemy_missile2.png +644 root root . home/maemo/quickhitdata/leveltwo/gfx/fire.png debian/levelone/home/maemo/quickhitdata/leveltwo/gfx/fire.png +644 root root . home/maemo/quickhitdata/leveltwo/gfx/fire2.png debian/levelone/home/maemo/quickhitdata/leveltwo/gfx/fire2.png +644 root root . home/maemo/quickhitdata/leveltwo/gfx/missile.png debian/levelone/home/maemo/quickhitdata/leveltwo/gfx/missile.png +644 root root . home/maemo/quickhitdata/leveltwo/gfx/missile2.png debian/levelone/home/maemo/quickhitdata/leveltwo/gfx/missile2.png +644 root root . home/maemo/quickhitdata/leveltwo/gfx/moon.png debian/levelone/home/maemo/quickhitdata/leveltwo/gfx/moon.png +644 root root . home/maemo/quickhitdata/leveltwo/gfx/ship.png debian/levelone/home/maemo/quickhitdata/leveltwo/gfx/ship.png +644 root root . home/maemo/quickhitdata/leveltwo/gfx/star3.png debian/levelone/home/maemo/quickhitdata/leveltwo/gfx/star3.png +644 root root . home/maemo/quickhitdata/leveltwo/gfx/transparent.png debian/levelone/home/maemo/quickhitdata/leveltwo/gfx/transparent.png +755 root root . home/maemo/quickhitdata/leveltwo/sound / +644 root root . home/maemo/quickhitdata/leveltwo/sound/crash.wav debian/levelone/home/maemo/quickhitdata/leveltwo/sound/crash.wav +644 root root . home/maemo/quickhitdata/leveltwo/sound/enemy_explosion.wav debian/levelone/home/maemo/quickhitdata/leveltwo/sound/enemy_explosion.wav +644 root root . home/maemo/quickhitdata/leveltwo/sound/laser.wav debian/levelone/home/maemo/quickhitdata/leveltwo/sound/laser.wav +644 root root . home/maemo/quickhitdata/leveltwo/sound/myship_explosion.wav debian/levelone/home/maemo/quickhitdata/leveltwo/sound/myship_explosion.wav +644 root root . home/maemo/quickhitdata/leveltwo/sound/rocket.wav debian/levelone/home/maemo/quickhitdata/leveltwo/sound/rocket.wav +644 root root . home/maemo/quickhitdata/leveltwo/sound/rocket_explosion.wav debian/levelone/home/maemo/quickhitdata/leveltwo/sound/rocket_explosion.wav +755 root root . usr / +755 root root . usr/bin / +755 root root . usr/lib / +755 root root . usr/lib/qt4 / +755 root root . usr/lib/qt4/plugins / +755 root root . usr/lib/qt4/plugins/quickhitlevels / +644 root root . usr/lib/qt4/plugins/quickhitlevels/libleveltwo.so debian/levelone/usr/lib/qt4/plugins/quickhitlevels/libleveltwo.so +755 root root . usr/share / +755 root root . usr/share/applications / +755 root root . usr/share/applications/hildon / +755 root root . usr/share/doc / +755 root root . usr/share/doc/levelone / +644 root root . usr/share/doc/levelone/changelog.gz debian/levelone/usr/share/doc/levelone/changelog.gz +644 root root . usr/share/doc/levelone/copyright debian/levelone/usr/share/doc/levelone/copyright diff --git a/demos/mobile/quickhit/plugins/LevelTwo/debian/postinst b/demos/mobile/quickhit/plugins/LevelTwo/debian/postinst new file mode 100644 index 0000000..79fb6dd --- /dev/null +++ b/demos/mobile/quickhit/plugins/LevelTwo/debian/postinst @@ -0,0 +1,5 @@ +#!/bin/sh -e + +gtk-update-icon-cache -f /usr/share/icons/hicolor + +exit 0 diff --git a/demos/mobile/quickhit/plugins/LevelTwo/debian/rules b/demos/mobile/quickhit/plugins/LevelTwo/debian/rules new file mode 100644 index 0000000..5dac6e0 --- /dev/null +++ b/demos/mobile/quickhit/plugins/LevelTwo/debian/rules @@ -0,0 +1,91 @@ +#!/usr/bin/make -f +# -*- makefile -*- +# Sample debian/rules that uses debhelper. +# This file was originally written by Joey Hess and Craig Small. +# As a special exception, when this file is copied by dh-make into a +# dh-make output file, you may use that output file without restriction. +# This special exception was added by Craig Small in version 0.37 of dh-make. + +# Uncomment this to turn on verbose mode. +#export DH_VERBOSE=1 + + +APPNAME := leveltwo + + +configure: configure-stamp +configure-stamp: + dh_testdir + # Add here commands to configure the package. + + touch configure-stamp + + +build: build-stamp + +build-stamp: configure-stamp + dh_testdir + + # Add here commands to compile the package. + $(MAKE) + #docbook-to-man debian/$(APPNAME).sgml > $(APPNAME).1 + + touch $@ + +clean: + dh_testdir + dh_testroot + rm -f build-stamp configure-stamp + + # Add here commands to clean up after the build process. + $(MAKE) clean + + dh_clean + +install: build + dh_testdir + dh_testroot + dh_clean -k + dh_installdirs + + # Add here commands to install the package into debian/$(APPNAME). + $(MAKE) INSTALL_ROOT="$(CURDIR)"/debian/$(APPNAME) install + + +# Build architecture-independent files here. +binary-indep: build install +# We have nothing to do by default. + +# Build architecture-dependent files here. +binary-arch: build install + dh_testdir + dh_testroot + dh_installchangelogs + dh_installdocs + dh_installexamples +# dh_install +# dh_installmenu +# dh_installdebconf +# dh_installlogrotate +# dh_installemacsen +# dh_installpam +# dh_installmime +# dh_python +# dh_installinit +# dh_installcron +# dh_installinfo + dh_installman + dh_link + # dh_strip + dh_compress + dh_fixperms +# dh_perl + dh_makeshlibs + dh_installdeb + dh_shlibdeps + dh_gencontrol + dh_md5sums + dh_builddeb + +binary: binary-indep binary-arch +.PHONY: build clean binary-indep binary-arch binary install configure diff --git a/demos/mobile/quickhit/plugins/LevelTwo/gfx/background2.png b/demos/mobile/quickhit/plugins/LevelTwo/gfx/background2.png Binary files differnew file mode 100644 index 0000000..8fbf2f4 --- /dev/null +++ b/demos/mobile/quickhit/plugins/LevelTwo/gfx/background2.png diff --git a/demos/mobile/quickhit/plugins/LevelTwo/gfx/background_loop.png b/demos/mobile/quickhit/plugins/LevelTwo/gfx/background_loop.png Binary files differnew file mode 100644 index 0000000..3a135d2 --- /dev/null +++ b/demos/mobile/quickhit/plugins/LevelTwo/gfx/background_loop.png diff --git a/demos/mobile/quickhit/plugins/LevelTwo/gfx/blue_fire.png b/demos/mobile/quickhit/plugins/LevelTwo/gfx/blue_fire.png Binary files differnew file mode 100644 index 0000000..8667a39 --- /dev/null +++ b/demos/mobile/quickhit/plugins/LevelTwo/gfx/blue_fire.png diff --git a/demos/mobile/quickhit/plugins/LevelTwo/gfx/enemy1.png b/demos/mobile/quickhit/plugins/LevelTwo/gfx/enemy1.png Binary files differnew file mode 100644 index 0000000..94f149b --- /dev/null +++ b/demos/mobile/quickhit/plugins/LevelTwo/gfx/enemy1.png diff --git a/demos/mobile/quickhit/plugins/LevelTwo/gfx/enemy_missile2.png b/demos/mobile/quickhit/plugins/LevelTwo/gfx/enemy_missile2.png Binary files differnew file mode 100644 index 0000000..5011d75 --- /dev/null +++ b/demos/mobile/quickhit/plugins/LevelTwo/gfx/enemy_missile2.png diff --git a/demos/mobile/quickhit/plugins/LevelTwo/gfx/fire.png b/demos/mobile/quickhit/plugins/LevelTwo/gfx/fire.png Binary files differnew file mode 100644 index 0000000..8401034 --- /dev/null +++ b/demos/mobile/quickhit/plugins/LevelTwo/gfx/fire.png diff --git a/demos/mobile/quickhit/plugins/LevelTwo/gfx/fire2.png b/demos/mobile/quickhit/plugins/LevelTwo/gfx/fire2.png Binary files differnew file mode 100644 index 0000000..139aa61 --- /dev/null +++ b/demos/mobile/quickhit/plugins/LevelTwo/gfx/fire2.png diff --git a/demos/mobile/quickhit/plugins/LevelTwo/gfx/missile.png b/demos/mobile/quickhit/plugins/LevelTwo/gfx/missile.png Binary files differnew file mode 100644 index 0000000..86bb41b --- /dev/null +++ b/demos/mobile/quickhit/plugins/LevelTwo/gfx/missile.png diff --git a/demos/mobile/quickhit/plugins/LevelTwo/gfx/missile2.png b/demos/mobile/quickhit/plugins/LevelTwo/gfx/missile2.png Binary files differnew file mode 100644 index 0000000..dacd610 --- /dev/null +++ b/demos/mobile/quickhit/plugins/LevelTwo/gfx/missile2.png diff --git a/demos/mobile/quickhit/plugins/LevelTwo/gfx/ship.png b/demos/mobile/quickhit/plugins/LevelTwo/gfx/ship.png Binary files differnew file mode 100644 index 0000000..cb7851c --- /dev/null +++ b/demos/mobile/quickhit/plugins/LevelTwo/gfx/ship.png diff --git a/demos/mobile/quickhit/plugins/LevelTwo/gfx/star3.png b/demos/mobile/quickhit/plugins/LevelTwo/gfx/star3.png Binary files differnew file mode 100644 index 0000000..70af0f3 --- /dev/null +++ b/demos/mobile/quickhit/plugins/LevelTwo/gfx/star3.png diff --git a/demos/mobile/quickhit/plugins/LevelTwo/gfx/transparent.png b/demos/mobile/quickhit/plugins/LevelTwo/gfx/transparent.png Binary files differnew file mode 100644 index 0000000..3aa1e41 --- /dev/null +++ b/demos/mobile/quickhit/plugins/LevelTwo/gfx/transparent.png diff --git a/demos/mobile/quickhit/plugins/LevelTwo/leveltwo.cpp b/demos/mobile/quickhit/plugins/LevelTwo/leveltwo.cpp new file mode 100644 index 0000000..45a39e3 --- /dev/null +++ b/demos/mobile/quickhit/plugins/LevelTwo/leveltwo.cpp @@ -0,0 +1,122 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "leveltwo.h" +#include <QtCore/qplugin.h> + + +LevelTwo::LevelTwo() +{ +} + +LevelTwo::~LevelTwo() +{ +} + +QString LevelTwo::pathPrefix() +{ + /* +QDir::rootPath() +For Unix operating systems this returns "/". +For Windows file systems this normally returns "c:/". +On Symbian this typically returns "c:/data", +*/ + +#ifdef Q_WS_MAEMO_5 + return "/home/user/."; +#elif defined Q_OS_WIN32 + return QDir::rootPath(); +#else + //return QDir::rootPath()+"/"; + return "c:/System/"; +#endif +} + +QStringList LevelTwo::levelSounds() +{ + QStringList list; + + + // NOTE: Mandatory sounds/indexs for the all levels + // 0 = Enemy explode + list.append(LevelTwo::pathPrefix()+"quickhitdata/leveltwo/sound/enemy_explosion.wav"); + // 1 = You explode + list.append(LevelTwo::pathPrefix()+"quickhitdata/leveltwo/sound/myship_explosion.wav"); + // 2 = Missile fires + list.append(LevelTwo::pathPrefix()+"quickhitdata/leveltwo/sound/laser.wav"); + // 3 = Emeny Missile fires + list.append(LevelTwo::pathPrefix()+"quickhitdata/leveltwo/sound/rocket.wav"); + + // Additional sounds + list.append(LevelTwo::pathPrefix()+"quickhitdata/leveltwo/sound/enableship.wav"); + list.append(LevelTwo::pathPrefix()+"quickhitdata/leveltwo/sound/level2.wav"); + + + return list; +} + +QVariant LevelTwo::getData(QVariant key) +{ + QVariant ret; + switch (key.toInt()) { + case 1: { + // Any data what you need for this key + // Set your data into QVariant (ret) + break; + } + default: { + break; + } + } + return ret; +} + +QVariant LevelTwo::graphSize(QVariant pathToGraph) +{ + QVariant ret; + m_imageReader.setFileName(pathToGraph.toString()); + QSize imageSize = m_imageReader.size(); + ret.setValue(imageSize); + return ret; +} + +// This Qt macro exports the plugin class LevelTwo with the name levelplugins. +// There should be exactly one occurrence of this LevelTwo macro in a Qt plugin's source code. +Q_EXPORT_PLUGIN2(levelplugins, LevelTwo); diff --git a/demos/mobile/quickhit/plugins/LevelTwo/leveltwo.h b/demos/mobile/quickhit/plugins/LevelTwo/leveltwo.h new file mode 100644 index 0000000..b983210 --- /dev/null +++ b/demos/mobile/quickhit/plugins/LevelTwo/leveltwo.h @@ -0,0 +1,91 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef LevelTwo_H +#define LevelTwo_H + +#include <QObject> +#include <QDir> +#include <QImageReader> + +#include "levelplugininterface.h" + +class LevelTwo : public LevelPluginInterface +{ + Q_OBJECT + + // This macro tells Qt which interfaces the class implements. + // This is used when implementing plugins. + Q_INTERFACES(LevelPluginInterface) + +public: + LevelTwo(); + ~LevelTwo(); + + static QString pathPrefix(); + +public: // From LevelPluginInterface + + QStringList levelSounds(); + + Q_INVOKABLE QVariant getData(QVariant key); + + Q_INVOKABLE QVariant graphSize(QVariant pathToGraph); + + Q_INVOKABLE QVariant enemyCount() { return QVariant(35); } + Q_INVOKABLE QVariant enemyRowCount() { return QVariant(0); } + Q_INVOKABLE QVariant enemySpeed() { return QVariant(20000); } + Q_INVOKABLE QVariant enemyFireSpeed() { return QVariant(500); } + + // Root paths for the QML, Pictures and Sounds + Q_INVOKABLE QVariant qmlRootPath() { return QVariant(LevelTwo::pathPrefix()+"quickhitdata/leveltwo/"); } + Q_INVOKABLE QVariant pictureRootPath() { return QVariant(LevelTwo::pathPrefix()+"quickhitdata/leveltwo/gfx/"); } + + // Full paths + Q_INVOKABLE QVariant pathToTransparentEnemyPic() {return QVariant(LevelTwo::pathPrefix()+"quickhitdata/leveltwo/gfx/transparent.png");} + Q_INVOKABLE QVariant pathToMissilePic() {return QVariant(LevelTwo::pathPrefix()+"quickhitdata/leveltwo/gfx/missile2.png");} + Q_INVOKABLE QVariant pathToEnemyMissilePic() {return QVariant(LevelTwo::pathPrefix()+"quickhitdata/leveltwo/gfx/enemy_missile2.png");} + Q_INVOKABLE QVariant pathToMyShipPic() {return QVariant(LevelTwo::pathPrefix()+"quickhitdata/leveltwo/gfx/ship.png");} + +protected: + QImageReader m_imageReader; +}; + +#endif // LevelTwo_H diff --git a/demos/mobile/quickhit/plugins/LevelTwo/leveltwo.pro b/demos/mobile/quickhit/plugins/LevelTwo/leveltwo.pro new file mode 100644 index 0000000..171ee6c --- /dev/null +++ b/demos/mobile/quickhit/plugins/LevelTwo/leveltwo.pro @@ -0,0 +1,108 @@ + +# Copyright (c) 2010 Nokia Corporation. + +TEMPLATE = lib + +#VERSION = 1.1.0 + +CONFIG += plugin + +INCLUDEPATH += ../ + +HEADERS = leveltwo.h + +SOURCES = leveltwo.cpp + +TARGET = $$qtLibraryTarget(leveltwo) + +OTHER_FILES += qml/Level.qml \ + qml/Enemy.qml \ + qml/Level.js + + +# SYMBIAN --------------------------- +symbian: { +# Load predefined include paths (e.g. QT_PLUGINS_BASE_DIR) to be used in the pro-files +load(data_caging_paths) + +# EPOCALLOWDLLDATA have to set true because Qt macros has initialised global data +TARGET.EPOCALLOWDLLDATA=1 +TARGET.UID3 = 0xE07dfb67 + +TARGET.CAPABILITY = NetworkServices \ + Location \ + ReadUserData \ + WriteUserData \ + LocalServices \ + UserEnvironment + +# Defines plugin stub file into Symbian .pkg package +pluginDep.sources = leveltwo.dll +pluginDep.path = $$QT_PLUGINS_BASE_DIR/quickhitlevels +DEPLOYMENT += pluginDep + +# Graphics and Sounds for the plugin +BLD_INF_RULES.prj_exports += "gfx/background2.png ../winscw/c/Data/gfx/background2.png" \ +"gfx/background_loop.png ../winscw/c/Data/gfx/background_loop.png" \ +"gfx/enemy1.png ../winscw/c/Data/gfx/enemy1.png" \ +"gfx/fire2.png ../winscw/c/Data/gfx/fire2.png" \ +"gfx/fire.png ../winscw/c/Data/gfx/fire.png" \ +"gfx/missile2.png ../winscw/c/Data/gfx/missile2.png" \ +"gfx/enemy_missile2.png ../winscw/c/Data/gfx/enemy_missile2.png" \ +"gfx/ship.png ../winscw/c/Data/gfx/ship.png" \ +"gfx/transparent.png ../winscw/c/Data/gfx/transparent.png" \ +"gfx/star3.png ../winscw/c/Data/gfx/star3.png" \ +"gfx/blue_fire.png ../winscw/c/Data/gfx/blue_fire.png" \ +"sound/enemy_explosion.wav ../winscw/c/Data/sound/enemy_explosion.wav" \ +"sound/myship_explosion.wav ../winscw/c/Data/sound/myship_explosion.wav" \ +"sound/enableship.wav ../winscw/c/Data/sound/enableship.wav" \ +"sound/laser.wav ../winscw/c/Data/sound/laser.wav" \ +"sound/level2.wav ../winscw/c/Data/sound/level2.wav" \ +"qml/Level.qml ../winscw/c/Data/Level.qml" \ +"qml/Level.js ../winscw/c/Data/Level.js" \ +"qml/Enemy.qml ../winscw/c/Data/Enemy.qml" + + +myQml.sources = qml/* +myQml.path = c:/System/quickhitdata/leveltwo +myGraphic.sources = gfx/* +myGraphic.path = c:/System/quickhitdata/leveltwo/gfx +mySound.sources = sound/* +mySound.path = c:/System/quickhitdata/leveltwo/sound +# Takes qml, graphics and sounds into Symbian SIS package file (.pkg) +DEPLOYMENT += myQml myGraphic mySound + +target.path += $$[QT_INSTALL_PLUGINS]/quickhitlevels +# Installs binaries +INSTALLS += target +} + +# WINDOWS --------------------------- +win32: { + +# Copy level sounds and graphics into right destination +system(mkdir c:\quickhitdata\leveltwo) +system(mkdir c:\quickhitdata\leveltwo\gfx) +system(mkdir c:\quickhitdata\leveltwo\sound) +system(copy qml\*.* c:\quickhitdata\leveltwo) +system(copy gfx\*.* c:\quickhitdata\leveltwo\gfx) +system(copy sound\*.* c:\quickhitdata\leveltwo\sound) + +# Installs binaries +target.path += $$[QT_INSTALL_PLUGINS]/quickhitlevels +INSTALLS += target +} + +# MAEMO_5 --------------------------- +maemo5: { +myQml.path = /home/user/.quickhitdata/leveltwo/ +myQml.files += qml/* +myGraphic.path = /home/user/.quickhitdata/leveltwo/gfx/ +myGraphic.files += gfx/* +mySound.path = /home/user/.quickhitdata/leveltwo/sound/ +mySound.files += sound/* + +target.path += /usr/lib/qt4/plugins/quickhitlevels +# Installs qml, binaries, sounds and graphics +INSTALLS += target myGraphic mySound myQml +} diff --git a/demos/mobile/quickhit/plugins/LevelTwo/qml/Enemy.qml b/demos/mobile/quickhit/plugins/LevelTwo/qml/Enemy.qml new file mode 100644 index 0000000..1b489b2 --- /dev/null +++ b/demos/mobile/quickhit/plugins/LevelTwo/qml/Enemy.qml @@ -0,0 +1,84 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 1.0 + +Image { + id: enemy + objectName: "enemy" + smooth:true + opacity: 0 // 0=hidden by default + fillMode:Image.PreserveAspectFit + source:"file:/"+LevelPlugin.pictureRootPath()+"enemy1.png" + + property int enemySpeed: LevelPlugin.enemySpeed() + + function pause(doPause) { + if (doPause) { + upToDownAnim.pause() + rightLeftAnim.pause() + } else { + upToDownAnim.resume() + rightLeftAnim.resume() + } + } + + function startMovingAnim() { + upToDownAnim.restart() + rightLeftAnim.restart() + } + + // Right-left animation + SequentialAnimation { + id: rightLeftAnim + loops: Animation.Infinite + NumberAnimation { target:enemy; property:"x"; + to:gameArea.width - enemy.width; easing.type: Easing.OutQuad; duration: 3000 } + NumberAnimation { target:enemy; property:"x"; to:0; easing.type: Easing.OutQuad; duration: 3000 } + } + + // Up to down animation + SequentialAnimation { + id: upToDownAnim + PropertyAnimation { target:enemy; property:"y"; to: gameArea.height; + easing.type: Easing.Linear; duration: enemy.enemySpeed } + PropertyAction { target: enemy; properties: "opacity"; value: 0 } + } +} diff --git a/demos/mobile/quickhit/plugins/LevelTwo/qml/Level.js b/demos/mobile/quickhit/plugins/LevelTwo/qml/Level.js new file mode 100644 index 0000000..e2e1d3a --- /dev/null +++ b/demos/mobile/quickhit/plugins/LevelTwo/qml/Level.js @@ -0,0 +1,42 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ + +var hiddenEnemies = new Array() + diff --git a/demos/mobile/quickhit/plugins/LevelTwo/qml/Level.qml b/demos/mobile/quickhit/plugins/LevelTwo/qml/Level.qml new file mode 100644 index 0000000..69a6593 --- /dev/null +++ b/demos/mobile/quickhit/plugins/LevelTwo/qml/Level.qml @@ -0,0 +1,228 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 1.0 +import Qt.labs.particles 1.0 +import "Level.js" as LevelScript + +Item { + id: enemies + anchors.fill: parent + + property int enemiesCreated: 0 + property int enemiesEnabled: 0 + + property int backOneTop + property int backTwoTop + + // Long background 2 + Image { + id: longBackground_2 + source: "file:/"+LevelPlugin.pictureRootPath()+"background_loop.png" + fillMode: Image.Stretch + smooth: false + width: gameArea.width + height: gameArea.height + } + + // Long background 1 + Image { + id: longBackground_1 + source: "file:/"+LevelPlugin.pictureRootPath()+"background_loop.png" + fillMode: Image.Stretch + smooth: false + width: gameArea.width + height: gameArea.height + } + + // Long background Up to down animation + ParallelAnimation { + id: backgroundAnim; + loops: Animation.Infinite + PropertyAnimation { target:longBackground_1; property:"y"; + from:backOneTop; to:gameArea.height; easing.type:Easing.Linear; duration:10000 } + PropertyAnimation { target:longBackground_2; property:"y"; + from:backTwoTop; to:backOneTop; easing.type:Easing.Linear; duration:10000 } + } + + + + // *************************************************** + // *** NOTE: This is mandatory for all level QML files + function pause(doPause) { + if (doPause) { + enemyCreationTimer.stop() + backgroundAnim.stop() + } else { + enemyCreationTimer.restart() + backgroundAnim.restart() + } + for (var i=0;i<LevelScript.hiddenEnemies.length;i++) { + var enemy = LevelScript.hiddenEnemies[i] + enemy.pause(doPause) + } + } + + + // *************************************************** + // *** NOTE: This is mandatory for all level QML files + objectName: "level" + + + // Enemy creation timer + Timer { + id: enemyCreationTimer + interval: 1000; running: false; repeat: true + onTriggered: { + enableEnemy() + } + } + + function enableEnemy() { + if (enemiesEnabled < enemiesCreated) { + var enemy = LevelScript.hiddenEnemies[enemiesEnabled] + enemy.opacity = 1 + enemy.x = GameEngine.randInt(0,gameArea.width-enemy.width-50) + enemy.startMovingAnim() + enemyCreationTimer.stop() + enemyCreationTimer.interval = GameEngine.randInt(500,2000) + enemyCreationTimer.restart() + enemiesEnabled = enemiesEnabled + 1 + GameEngine.playSound(4) // NOTE: Enable enemy sound + } else { + enemyCreationTimer.stop() + } + } + + // Hidden enemies group + function createHiddenEnemiesGroup() { + for (var i=0;i<LevelPlugin.enemyCount();i++) { + var enemyComponent = Qt.createComponent("file:/"+LevelPlugin.qmlRootPath()+"Enemy.qml") + var enemyObject = enemyComponent.createObject(enemies) + LevelScript.hiddenEnemies.push(enemyObject) + enemiesCreated = enemiesCreated + 1 + } + } + + Component.onCompleted: { + // Create hidden enemies + createHiddenEnemiesGroup() + // Flying moons animation + starBurstTimer.restart() + // Create enemies timer + enemyCreationTimer.restart() + + // Start Long background loop animation + backOneTop = 0 + longBackground_1.y = backOneTop; + backTwoTop = gameArea.height * -1 + longBackground_2.y = backTwoTop; + backgroundAnim.restart() + + GameEngine.playSounds(5,3) //NOTE: Level starts sound, 3 times + } + + Timer { + id: starBurstTimer + interval: starParticles.lifeSpan+GameEngine.randInt(100,2000); running: false; repeat: true + onTriggered: { + starParticles.burst(GameEngine.randInt(4,6)) + } + } + + // *************************************************** + // *** NOTE: This is mandatory for all level QML files + // Execute explode particle effect + function explode(x,y) { + explodeParticles.x = x + explodeParticles.y = y + explodeParticles.burst(20) + explodeParticles.opacity = 1 + } + // *************************************************** + // *** NOTE: This is mandatory for all level QML files + // Explode particle effect + Particles { + id: explodeParticles + opacity: 0 + width: 1 + height: 1 + emissionRate: 0 + source: "file:/"+LevelPlugin.pictureRootPath()+"blue_fire.png" + lifeSpan: 500 + lifeSpanDeviation: 2000 + count: -1 + angle: 270 + angleDeviation: 65 + velocity: 100 + velocityDeviation: 100 + ParticleMotionGravity { + yattractor: 1000 + xattractor: 300 + acceleration: 50 + } + } + + Particles { + id: starParticles + y: -50 + x: 0 + width: parent.width + height: 50 + emissionRate: 0 + source: "file:/"+LevelPlugin.pictureRootPath()+"star3.png" + lifeSpan: 5000 + count: -1 + angle: 90 + velocity: 100 + opacity: 0.7 + ParticleMotionGravity { + yattractor: 1000 + xattractor: 500 + } + } + + +} + + + + + diff --git a/demos/mobile/quickhit/plugins/LevelTwo/sound/crash.wav b/demos/mobile/quickhit/plugins/LevelTwo/sound/crash.wav Binary files differnew file mode 100644 index 0000000..8076f0f --- /dev/null +++ b/demos/mobile/quickhit/plugins/LevelTwo/sound/crash.wav diff --git a/demos/mobile/quickhit/plugins/LevelTwo/sound/enableship.wav b/demos/mobile/quickhit/plugins/LevelTwo/sound/enableship.wav Binary files differnew file mode 100644 index 0000000..6fe5fe8 --- /dev/null +++ b/demos/mobile/quickhit/plugins/LevelTwo/sound/enableship.wav diff --git a/demos/mobile/quickhit/plugins/LevelTwo/sound/enemy_explosion.wav b/demos/mobile/quickhit/plugins/LevelTwo/sound/enemy_explosion.wav Binary files differnew file mode 100644 index 0000000..fd338e6 --- /dev/null +++ b/demos/mobile/quickhit/plugins/LevelTwo/sound/enemy_explosion.wav diff --git a/demos/mobile/quickhit/plugins/LevelTwo/sound/laser.wav b/demos/mobile/quickhit/plugins/LevelTwo/sound/laser.wav Binary files differnew file mode 100644 index 0000000..c3b58b2 --- /dev/null +++ b/demos/mobile/quickhit/plugins/LevelTwo/sound/laser.wav diff --git a/demos/mobile/quickhit/plugins/LevelTwo/sound/level2.wav b/demos/mobile/quickhit/plugins/LevelTwo/sound/level2.wav Binary files differnew file mode 100644 index 0000000..24d3917 --- /dev/null +++ b/demos/mobile/quickhit/plugins/LevelTwo/sound/level2.wav diff --git a/demos/mobile/quickhit/plugins/LevelTwo/sound/myship_explosion.wav b/demos/mobile/quickhit/plugins/LevelTwo/sound/myship_explosion.wav Binary files differnew file mode 100644 index 0000000..e22d030 --- /dev/null +++ b/demos/mobile/quickhit/plugins/LevelTwo/sound/myship_explosion.wav diff --git a/demos/mobile/quickhit/plugins/LevelTwo/sound/rocket.wav b/demos/mobile/quickhit/plugins/LevelTwo/sound/rocket.wav Binary files differnew file mode 100644 index 0000000..8c0dee9 --- /dev/null +++ b/demos/mobile/quickhit/plugins/LevelTwo/sound/rocket.wav diff --git a/demos/mobile/quickhit/plugins/LevelTwo/sound/rocket_explosion.wav b/demos/mobile/quickhit/plugins/LevelTwo/sound/rocket_explosion.wav Binary files differnew file mode 100644 index 0000000..d2b451c --- /dev/null +++ b/demos/mobile/quickhit/plugins/LevelTwo/sound/rocket_explosion.wav diff --git a/demos/mobile/quickhit/plugins/levelplugininterface.h b/demos/mobile/quickhit/plugins/levelplugininterface.h new file mode 100644 index 0000000..b8d5018 --- /dev/null +++ b/demos/mobile/quickhit/plugins/levelplugininterface.h @@ -0,0 +1,86 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef LEVELPLUGININTERFACE_H +#define LEVELPLUGININTERFACE_H + +#include <QObject> +#include <QVariant> + +class LevelPluginInterface : public QObject +{ +public: + // Full paths to level sounds + virtual QStringList levelSounds() = 0; + + // Generic key/value data + virtual QVariant getData(QVariant key) = 0; + + // Request picture size + virtual QVariant graphSize(QVariant pathToGraph) = 0; + + // Enemy count in the level + virtual QVariant enemyCount() = 0; + // Enemy row count in the level + virtual QVariant enemyRowCount() = 0; + // Enemy speed + virtual QVariant enemySpeed() = 0; + // Enemy fire speed + virtual QVariant enemyFireSpeed() = 0; + + // QML root path + virtual QVariant qmlRootPath() = 0; + // Picture root path + virtual QVariant pictureRootPath() = 0; + + // Paths for GameEngine and QuickHit internal QML files + virtual QVariant pathToTransparentEnemyPic() = 0; + virtual QVariant pathToMissilePic() = 0; + virtual QVariant pathToEnemyMissilePic() = 0; + virtual QVariant pathToMyShipPic() = 0; +}; + +// This Qt macro associates the given Identifier "Forum.Nokia.com.QuickHit.LevelPluginInterface/1.0" +// to the interface class called LevelPluginInterface. The Identifier must be unique. +Q_DECLARE_INTERFACE(LevelPluginInterface, + "Forum.Nokia.com.QuickHit.LevelPluginInterface/1.0"); + + +#endif // LEVELPLUGININTERFACE_H diff --git a/demos/mobile/quickhit/quickhit.png b/demos/mobile/quickhit/quickhit.png Binary files differnew file mode 100644 index 0000000..01d2d60 --- /dev/null +++ b/demos/mobile/quickhit/quickhit.png diff --git a/demos/mobile/quickhit/quickhit.pro b/demos/mobile/quickhit/quickhit.pro new file mode 100644 index 0000000..e5a4b3d --- /dev/null +++ b/demos/mobile/quickhit/quickhit.pro @@ -0,0 +1,91 @@ + +# Copyright (c) 2011 Nokia Corporation. + +QT += core gui declarative opengl + +VERSION = 1.1.1 + +TARGET = quickhit +TEMPLATE = app + +SOURCES += main.cpp \ + mainwindow.cpp \ + gameengine.cpp \ + InvSounds.cpp \ + myeventfilter.cpp \ + ga_src/GEAudioBuffer.cpp \ + ga_src/GEAudioOut.cpp \ + ga_src/GEInterfaces.cpp + +HEADERS += mainwindow.h \ + gameengine.h \ + myeventfilter.h \ + plugins/levelplugininterface.h \ + InvSounds.h \ + ga_src/GEAudioBuffer.h \ + ga_src/GEAudioOut.h \ + ga_src/GEInterfaces.h + +RESOURCES += resources.qrc + +# QtMultimedia from Qt +QT += multimedia + +symbian { + # in Symbian 1 we do not have OpenGL available + contains(SYMBIAN_VERSION, 9.4) { + DEFINES += QT_NO_OPENGL + QT -= opengl + warning("No OpenGL support") + } + + CONFIG += mobility + MOBILITY = systeminfo + TARGET = QuickHit + TARGET.UID3 = 0xe7ced714 + + TARGET.CAPABILITY = NetworkServices \ + Location \ + ReadUserData \ + WriteUserData \ + LocalServices \ + UserEnvironment + + LIBS += -lcone -leikcore -lavkon -lhwrmvibraclient + + ICON = icon.svg + + TARGET.EPOCSTACKSIZE = 0x14000 + TARGET.EPOCHEAPSIZE = 0x100000 0x2000000 +} + +maemo5 { + CONFIG += mobility + MOBILITY = systeminfo + + BINDIR = /opt/usr/bin + DATADIR = /usr/share + DEFINES += DATADIR=\\\"$$DATADIR\\\" \ + PKGDATADIR=\\\"$$PKGDATADIR\\\" + + INSTALLS += target \ + desktop \ + icon64 + + target.path = $$BINDIR + desktop.path = $$DATADIR/applications/hildon + desktop.files += quickhit.desktop + + icon64.path = $$DATADIR/icons/hicolor/64x64/apps + icon64.files += quickhit.png +} + +OTHER_FILES += \ + Game.qml \ + Game.js \ + MyShip.qml \ + Missile.qml \ + Menu.qml \ + MenuItem.qml \ + Button.qml \ + Message.qml diff --git a/demos/mobile/quickhit/resources.qrc b/demos/mobile/quickhit/resources.qrc new file mode 100644 index 0000000..8063bf7 --- /dev/null +++ b/demos/mobile/quickhit/resources.qrc @@ -0,0 +1,25 @@ +<RCC> + <qresource prefix="/"> + <file>Game.qml</file> + <file>Game.js</file> + <file>MyShip.qml</file> + <file>Missile.qml</file> + <file>Menu.qml</file> + <file>MenuItem.qml</file> + <file>Button.qml</file> + <file>Message.qml</file> + <file>gfx/back.png</file> + <file>gfx/exit.png</file> + <file>gfx/pause.png</file> + <file>gfx/soundOn.png</file> + <file>gfx/soundOff.png</file> + <file>gfx/background2.png</file> + <file>gfx/bigship.png</file> + <file>gfx/quickhit_logo.png</file> + <file>sound/menu1.wav</file> + <file>sound/menu2.wav</file> + <file>sound/gamestart.wav</file> + <file>sound/youwin.wav</file> + <file>sound/gameover.wav</file> + </qresource> +</RCC> diff --git a/demos/mobile/quickhit/sound/gameover.wav b/demos/mobile/quickhit/sound/gameover.wav Binary files differnew file mode 100644 index 0000000..e5b9e94 --- /dev/null +++ b/demos/mobile/quickhit/sound/gameover.wav diff --git a/demos/mobile/quickhit/sound/gamestart.wav b/demos/mobile/quickhit/sound/gamestart.wav Binary files differnew file mode 100644 index 0000000..8632fca --- /dev/null +++ b/demos/mobile/quickhit/sound/gamestart.wav diff --git a/demos/mobile/quickhit/sound/menu1.wav b/demos/mobile/quickhit/sound/menu1.wav Binary files differnew file mode 100644 index 0000000..586ab2c --- /dev/null +++ b/demos/mobile/quickhit/sound/menu1.wav diff --git a/demos/mobile/quickhit/sound/menu2.wav b/demos/mobile/quickhit/sound/menu2.wav Binary files differnew file mode 100644 index 0000000..70a61c1 --- /dev/null +++ b/demos/mobile/quickhit/sound/menu2.wav diff --git a/demos/mobile/quickhit/sound/youwin.wav b/demos/mobile/quickhit/sound/youwin.wav Binary files differnew file mode 100644 index 0000000..f48297d --- /dev/null +++ b/demos/mobile/quickhit/sound/youwin.wav |